Salesforce Geek

  • Home
  • Blog
  • Our Courses
  • Library
  • About Us
  • Contact Us

Edit Content
Custom Blog Image
LWC, Salesforce

Lightning Record Picker in Salesforce

November 24, 2023 Simran Thakur

Salesforce has recently announced the Lightning Record Picker component. Lightning-record-picker is available in Beta and shall be Generally Available (GA) in Spring ’24.

Moreover, the Lightning Record Picker component in Lightning web components (LWC) provides a user-friendly interface for selecting records. This makes the process of associating records much easier and more intuitive.

One notable feature of the Lightning Record Picker is its offline capability, ensuring a consistent user experience whether users are working online or offline.

Additionally, it is designed to be compatible with both desktop and mobile platforms, thereby enhancing its versatility.

In this example, we are also creating a simple lightning record picker component to search the Account records. To initialize, all we need is a label for the input field, the object name from which particular data would be searched, and a callback to handle the selection of the record.

lightningRecordPicker.html

lightningRecordPicker.js

Output:

https://salesforcegeek.in/wp-content/uploads/2023/11/LightningRecordPicker.webm

 

Also Read: Trigger Scenario-Based Questions in Salesforce

Lightning Record Picker with Dynamic Targets

The above example explains a Lighting record picker with a static filter, Let explore a lightning record picker with dynamic targets.

The record picker component offers strong capabilities to improve user interaction and data retrieval while integrating seamlessly with your page.

Additionally, you can add a placeholder, implement validation, and more. Moreover, this component provides various customizations that can be tailored based on our specific requirements.

1. Matching Fields: By default, it includes the object name. Moreover, on top of it, you can additionally display a field with text or formula field type. You can also use more fields for matching criteria.

2. Display Fields: Similarly, users appreciate it when we add a secondary field to aid in finding the correct record (especially when there are several records with similar names). Initially, we display the Name field.

3. Filtering: Record Picker gives you complete control over how records are filtered for your users, including the ability to mix custom logic, field types, and operators. Additionally, operator wildcards to SOQL are supported.

4. Validation: Validation is supported by the Record Picker component to guarantee user input and data integrity.

Validation messages may appear not only when you use the `reportValidity()` function but also when the component leaves focus. Moreover, SetCustomValidity() allows you to set custom validation messages as well.

lightningRecordPickerDynamic.html

lightningRecordPickerDynamic.js

Output :

https://salesforcegeek.in/wp-content/uploads/2023/11/Recordpickerwithdynamictargets.webm

 

In the above example, we have implemented the Lightning Record Picker with dynamic targets, incorporating various attributes such as DisplayInfo, matching info, and Filter.

Specifically, the Filter attributes include the Name field, ensuring that only account names containing “Company” will be displayed.

Get a complete Roadmap To Learn Salesforce Admin And Development

Share Now
  • Lightning Record Picker
  • LWC
Simran Thakur

Post navigation

Previous
Next

One comment

  1. Test Class In Salesforce - Salesforce Geek

    November 28, 2023 / 2:50 pm Reply

    […] Read More: Lightning Record Picker in Salesforce […]

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Salesforce Flows 👇 Beginner-friendly course | More than 90+ tutorials

Prepare for PD1 Exam 3 Mock Practice Sets to prepare for the exam

Book a 1:1 Call 👇 Doubt related to Salesforce Flow?

Categories

What’s Trending

  • With Sharing and Without Sharing in Apex
  • Difference between Setup and Non-Setup Objects in Salesforce
  • How to compare two Flow Versions in Salesforce
  • Salesforce and OpenAI Announce Major Partnership
  • XL-Connector for Salesforce: Bulk Field, Metadata, and Permission Management

Continue reading

LWC

Learn Salesforce LWC (Lightning Web Component) with Real time Projects

January 8, 2023 Harshit Sharma

What are Lighting Web Components? Lightning Web Components (LWC) is a modern programming model for building scalable and high-performance web applications on the Salesforce platform. It is an open-source JavaScript

Share Now

At SalesforceGeek, we believe learning Salesforce shouldn’t be complicated. We’ve been on a mission to make Salesforce education accessible, practical and engaging for everyone,

Quick Links
  • Blog Posts
  • Our Courses
  • Our Library
  • Contact Us
Our Latest Blogs
  • Adding Custom methods in Batch Apex with Example
  • Salesforce Lightning Design System 2 in Salesforce
  • Lightning Data Table in LWC
Get in touch
  • team@salesforcegeek.in
  • +91-9690995233

© Salesforcegeeks. All Rights Reserved.

  • Terms & Conditions
  • Privacy Policy