name: lwc-record-picker description: "lightning-record-picker base component (Winter '24 GA): object/record filter, displayInfo/matchingInfo, graph-ql filters, accessibility. Replaces ad-hoc lookup inputs. NOT for multi-select custom pickers (use lwc-multi-select-lookup). NOT for external-object lookup (use lwc-external-lookup)." category: lwc salesforce-version: "Spring '25+" well-architected-pillars: - User Experience - Operational Excellence tags: - lwc - record-picker - lookup - lightning-base-components - accessibility triggers: - "lightning record picker component lwc replace custom lookup" - "record picker display info matching info config" - "record picker filter graphql criteria" - "how to preselect value in record picker" - "record picker accessibility keyboard" - "record picker vs lightning lookup aura" inputs: - Target object API name - Fields to display / match - Filter criteria (graph-QL style) - Preselection value outputs: - Configured lightning-record-picker usage - Migration plan from legacy custom lookup - Test coverage with jest dependencies: [] version: 1.1.0 author: Pranav Nagrecha updated: 2026-05-19
LWC Record Picker
Activate when an LWC needs a user to search and select a single Salesforce record. lightning-record-picker (GA Winter '24) is the official base component; it replaces custom combobox+search implementations and hand-rolled lightning-lookup equivalents with one declarative tag.
Before Starting
- Use
lightning-record-pickerrather than rolling a custom lookup. - Configure
display-infoandmatching-info— they drive what the user sees and what fields search hits. - Set a filter for scoped choice lists (e.g., only active accounts).
Core Concepts
Minimum markup
<lightning-record-picker
label="Account"
placeholder="Search Accounts"
object-api-name="Account"
onchange={handleChange}>
</lightning-record-picker>
event.detail.recordId on change carries the selected record Id.
display-info / matching-info
<lightning-record-picker
object-api-name="Contact"
display-info={displayInfo}
matching-info={matchingInfo}>
</lightning-record-picker>
displayInfo = {
primaryField: 'Name',
additionalFields: ['Account.Name', 'Email']
};
matchingInfo = {
primaryField: { fieldPath: 'Name' },
additionalFields: [{ fieldPath: 'Email' }]
};
Filter (graph-QL)
filter = {
criteria: [
{ fieldPath: 'IsActive', operator: 'eq', value: true }
]
};
Limits search results.
Preselection
Set value={preselectedRecordId}. The picker fetches display fields and shows the chip.
Common Patterns
Pattern: Filtered contact picker scoped to account
Filter on AccountId = :this.accountId; filter updates when the account context changes.
Pattern: Multi-object picker via toggle
Two <lightning-record-picker> elements toggled by a dropdown that selects the object API name.
Pattern: Reset on context change
Programmatically set value = null (or re-query) when context changes.
Decision Guidance
| Need | Component |
|---|---|
| Standard single-record lookup | lightning-record-picker |
| Multi-record select | lightning-record-picker (not supported) → build custom |
| External object | lightning-record-picker does not support; custom |
| Enforce record-type filter | Use filter criteria on RecordTypeId |
| Filter by complex formula | Server-side Apex + custom combobox |
Recommended Workflow
- Confirm object is supported (standard + most custom). External objects unsupported.
- Define
display-infoandmatching-info— always set primaryField. - Build
filterwith graph-QL criteria for scope. - Wire
onchangeto capture selected Id and fetch additional record details. - Add accessibility attributes: label is required; leverage built-in keyboard nav.
- Write jest test asserting
changeevent dispatch. - Migrate any legacy custom lookup components to this one.
Review Checklist
-
lightning-record-pickerused instead of custom combobox -
object-api-namesupported by the base component -
display-infoprimaryField set -
matching-infomatches display -
filterscopes results to valid options -
onchangehandler capturesrecordId - Label is descriptive and required attribute set where mandatory
- Jest test covers change event
Salesforce-Specific Gotchas
- External Objects not supported. The picker targets standard/custom only.
- Person Account nuance — when Person Accounts are on,
Accountresults include persons; filter if you want companies only. matching-infois required for custom search fields — without it, only primary field matches.
Output Artifacts
| Artifact | Description |
|---|---|
| Picker config template | displayInfo / matchingInfo / filter examples |
| Migration plan | Legacy custom lookup → record-picker |
| Jest test helper | Mock event dispatch |
Related Skills
lwc/lwc-forms-patterns— picker embedded in formslwc/lwc-lookup-custom-patterns— when base picker is insufficientadmin/custom-field-creation— lookup field design