Skip to main content
Junte-se a nós na TDX em São Francisco ou no Salesforce+ nos dias 5 e 6 de maio e assista à Developer Conference for the AI Agent Era. Registre-se agora.

Get Hands-on with Lightning-Record-Picker

Learning Objectives

After completing this unit, you’ll be able to:

  • Implement and configure the lightning-record-picker.
  • Search for records with the lightning-record-picker component.

The lightning-record-picker component allows users to quickly find and select Salesforce records. You learn how to configure the component’s behavior and presentation, plus enable filtering so that users can retrieve and display the records they want. For the hands-on challenge, you use the component in a playground org to provide an additional way for customers to search inventory.

Search for Records with the Lightning-Record-Picker Component

Use the lightning-record-picker component in a Salesforce application so that desktop and mobile users can quickly find and select Salesforce records. Configure the component’s behavior and presentation, and enable filtering so that users can retrieve and display precisely the records that they want. This feature, now generally available, includes some changes since the previous release. You can now retrieve up to 100 records whereas previously, it was 50 records. The component also displays clear error messages when you configure invalid specifications and supports new attributes. This component uses the GraphQL wire adapter, which enables offline use.

Where: This feature is available for Lightning Experience in all editions.

How: Here’s an example to get started with the lightning-record-picker component. The component attributes provide the label for the input field, the object to search, and a callback to handle the selection of a record.

<lightning-record-picker
    label="Select a record"
    placeholder="Search..."
    object-api-name="Contact"
    value={initialValue}
    onchange={handleChange}
></lightning-record-picker>

Here’s what the example looks like in the UI.

UI implementation of the code.

Providing a record ID to thevalue attribute makes the record picker component display a default selected record.

UI displays the value for the record ID as Michael Jones.

In this unit, you learned how the lightning-record-picker allows users to find and select records and how you can tailor the component’s behavior and presentation. Now, you apply your knowledge of the lightning-record-picker component in a practical case involving a customer search in your boat inventory.

Desafio prático

+500 pontos

Prepare-se

Você concluirá este(a) unidade em sua própria organização prática. Clique em Iniciar para começar, ou clique no nome da sua organização para escolher uma diferente.

Seu desafio

Review updates to Salesforce to maintain your JavaScript Developer I Certification.
Implement and configure a lightning-record-picker component.

If you haven’t already completed unit 2, do that now. Otherwise, you won't be able to complete this challenge.
  • Update the boatPicker component
    • Configure the picker to display boat name as the main field and type as an additional field.
    • Configure the picker to search boat name as the main field and type as an additional field.
    • Configure the picker to change which boat is displayed when the selected record is changed.
  • To ensure the component is working as expected, deploy the boatPicker to the homepage of the Lightning Service application.
Compartilhe seu feedback do Trailhead usando a Ajuda do Salesforce.

Queremos saber sobre sua experiência com o Trailhead. Agora você pode acessar o novo formulário de feedback, a qualquer momento, no site Ajuda do Salesforce.

Saiba mais Continue compartilhando feedback