Lightning Record Picker in LWC

by Rijwan Mohmmed

Hello friends, today we will discuss Lightning Record Picker in LWC. It’s a powerful component that allows users to search, select, and link to Salesforce records, (like Lookup field) all within the comfort of your Lightning Web Component. Previously we used custom LWC lookup fields for this, and in this, we created a separate component. But now Salesforce has released a new component.

The Lightning Record Picker is a user interface component provided by Salesforce that allows users to search and select records from Salesforce objects such as Accounts, Contacts, Opportunities, and custom objects. It simplifies the process of record selection and can be used in various scenarios where users need to associate or link records.


Also, check this: Drag and Drop Fields in LWC

Key Highlights :

  1. User-Friendly: Simplify record selection for users, enhancing data accuracy and efficiency.
  2. Streamlined Workflow: Streamline processes by linking records directly within your LWC.
  3. Data Integrity: Ensure that related records are accurately associated with one another.
  4. Customization: Developers can configure the Lightning Record Picker to work with specific objects, define search filters, and even customize the appearance to match the application’s look and feel.
  5. Multi-Select mode: The Record Picker could support multi-select mode, enabling the selection of multiple records at once.
  6. No need for a custom lookup component.

Code :



	<lightning-card variant="Narrow" title="Lightning Record Picker in LWC" icon-name="standard:record_lookup">
		<div class="slds-p-horizontal_small">
			<lightning-record-picker label="Select a record" placeholder="Search..." object-api-name="Contact"
				onchange={handleChange} matching-info={matchingInfo} display-info={displayInfo} filter={filter}>
            <h3> Selected Record Id : {id} </h3>


import { LightningElement } from "lwc";

export default class RecordPickerWithFilter extends LightningElement {

    //on type we do search record according below marching where clouse
    matchingInfo = {
        primaryField: { fieldPath: "Name" },
        additionalFields: [{ fieldPath: "Email" }],

    displayInfo = {
        additionalFields: ["Email", "Title"],

    // filter Contacts having email
    filter = {
        criteria: [
                fieldPath: "Email",
                operator: "ne",
                value: "",

    handleChange(event) {
        console.log(`Selected record: ${event.detail.recordId}`); = event.detail.recordId;


<?xml version="1.0"?>
<LightningComponentBundle xmlns="">

Output :

Reference :

  1. Record Picker
  2. Lightning Record Picker Component
What’s your Reaction?

You may also like


appu January 9, 2024 - 12:59 pm

Hi Rijwan can we use this lightning record picker in the lightning data table instead of a custom component for lookup-related column.

Rijwan Mohmmed January 9, 2024 - 2:35 pm

Yes we can @Appu

Appu January 13, 2024 - 12:39 am

Hi Rijwan thanks for the reply. How can we add this lightning record picker inside the lightning data table?

Rijwan Mohmmed January 13, 2024 - 1:41 pm

Hi @Appu, Let me try this one

Rijwan Mohmmed January 13, 2024 - 2:17 pm

Hi @Appu, I tried with lightning record picker in LWC datatable and its working fine, Can you please schedule a meeting by below link, I will guide you

Appu January 15, 2024 - 7:01 am

Hi Rijwan, I scheduled a meeting from the given link for today at 10:00 PM IST.
But did not get any meeting link. Kindly share the link if I missed it.

Rijwan Mohmmed January 15, 2024 - 8:07 am

Hi @Appu, I got the your request. Join the meeting by topmate on given time.

Appu January 15, 2024 - 8:17 am

Hi Rijwan , I think I added the wrong email address on Topmate for scheduling the meeting.
How can I correct the email address?

Rijwan Mohmmed January 15, 2024 - 8:21 am

Login to Topmate and check your call

Rijwan Mohmmed January 15, 2024 - 8:22 am

Share me your email Id I will send the meeting link

Appu January 15, 2024 - 8:28 am

Thanks, a lot. My email address is

Maulik Vadodariya February 10, 2024 - 5:24 pm

I have use case where I want to initialize the record picker while components loads and then user can change by typing in so How to initialize the ?

Rijwan Mohmmed February 11, 2024 - 5:33 am

Hi Maulik, set a value in the record picker

Udaya March 1, 2024 - 1:30 pm

Can you please help how can we include lightning record picker as one of the column in LWC datatable


Leave a Comment