Codes
<template>
<lightning-record-picker
label="Select a record"
placeholder="Search..."
object-api-name="Contact"
onchange={handleChange}
matching-info={matchingInfo}
display-info={displayInfo}
filter={filter}>
</lightning-record-picker>
</template>
JavaScript
import { LightningElement } from 'lwc';
export default class RecordPickerWithFilter extends LightningElement {
matchingInfo = {
primaryField: { fieldPath: 'Name' },
additionalFields: [{ fieldPath: 'Title' }],
};
displayInfo = {
additionalFields: ['Title'],
};
// Filter Contacts having Accounts starting with "Madison"
filter = {
criteria: [
{
fieldPath: 'Account.Name',
operator: 'like',
value: 'Madison%',
},
],
};
handleChange(event) {
console.log('Selected record: ', event.detail.recordId);
}
}