- SalesforceChaCha
- Posts
- ๐ An immensely needed base LWC ๐บ
๐ An immensely needed base LWC ๐บ
OMG it's happening! ๐
Good morning, Salesforce Nerds! Today the ChaCha has some extra pep in our step! โก๏ธ๐๐บโก๏ธ
Some news that Iโve personally been waiting for years โ๏ธ to arrive just hit the Developer Blog the other day! ๐ฅณ
And my inner programming geek couldnโt be more stoked! ๐ค๐
Despite a handful of my legacy solutions now needing a refactor โฆ ๐ฒ
Today letโs spotlight ๐ฆ the addition of the Record Picker Component to the base LWC library!
Finally! ๐

oooof, gotta align this kind of dev work with their roadmap!
Agenda for today includes
An immensely needed base LWC
Daily Principle
All the Memes
An immensely needed base LWC
Today we will discuss -
๐ What is it? ๐บ
๐ Why should you care?๐บ
๐ Letโs see the code!๐บ
๐ค What is it?
First things first -
We gotta give it up ๐ for the Salesforce team building out the base Lightning Web Components!
The more this team churns out ๐, the more streamlined and powerful our front-end solutions can be! ๐ค
So kudos and a huge THANK YOU for your hard work. ๐ฏ
Okay, so what is the Record Picker Component and why is my nerdy dev heart ๐ going pitter patter over it?
Basically itโs this: ๐๏ธ
Think about the control that gets added to the Page when you drag a Lookup field ๐ onto the Layout.
It looks like this:

When the user clicks ๐ฑ๏ธ the control it displays a list of records from configured SObject type and allows for various ways of searching. ๐๏ธ
Weโre all familiar with this. ๐๏ธ
But, did you know ๐ค that despite there being scores of base LWCโs available to Salesforce devs - this was not one of them! โ๏ธ
Effectively, that means if your solution required a custom LWC that contained a Lookup field like the one above โ๏ธ then your dev team needs to build one from scratch or come up with an alternative. ๐
Through the years many of these โcustom, reusable Lookups in LWCโ surfaced and hit github. ๐๏ธ
They did the trick, but usually required a decent amount of development, testing, tweaking, etc.. ๐
๐คท Why should you care?
With the addition โ of a new base component your dev team wonโt need to spend any time -
Hashing out requirements related to building one of these
Actually developing one
Tweaking an existing one
Cursing LOUDLY when they need to update one - AGAIN
Take it from me.
While it was kinda cool to make one of these, that only lasted a little while. ๐ค
These got squirrely ๐ฟ๏ธ real quick!
We all know the only constant is change. ๐ซ
And that dude Russ from your payroll team is definitely going to break your implementation and then come to you with 7 change requests that donโt make any sense whatsoever. ๐
โฆ Russ. Why is it always Russ?! ๐
I digress.
Bottom line - you should care for two main reasons:
๐๏ธ Time - You and your devs are freed up to focus on important features for the business. Not boilerplate code to populate a simple Lookup field. โ
๐ช Reliability - Salesforce provides base LWCโs so we can use them as the building blocks of our custom apps. ๐ฆ๏ธ They give users a consistent look & feel, are matured/well-tested, simplify development effort, and are built using core Web Component standards. ๐คค
๐ป๏ธ Letโs see the code!
Like Linus Torvalds said -
Itโs hard to outline the code necessary to create one of these from scratch. ๐คทโโ๏ธ
But, we can check out a popular repo and get an idea ๐ก of what the LOE is to implement one.
Specifically - dig through the README file a bit and youโll see what I mean โฆ
This just gets you the core of what you need:
A way to run a SOQL query
Select a record
Pull the Id off the record
Now, tweak ๐ this so you can get all of Russโs stupid requests into it โฆ ๐
All of the sudden,๐ฅ BOOM๐ฅ, you now support a piece of ๐ฉ implementation.
Congratulations! ๐
Better days ๐๐ถ๏ธ๐ด are ahead, my friends.
Think of the Record Picker as your go-to Lightning Web Component that can quickly find and select Salesforce records.
All that will be required of your devs?
โ No Apex
โ No custom LWCโs
The following bit of code will get you up and running! ๐ฅ
recordPickerWithFilter.html
<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>
recordPickerWithFilter.js
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}`);
}
}
Trust me, from a developer perspective this is a big win! ๐
Check out the blog post and tech specs!
Then let your friendly Salesforce devs know this is happening! ๐๐บ
Daily Principle
โThe most disastrous thing that you can ever learn is your first programming language.โ
and now....Your Daily Memes

lethal force warranted

aw, it ainโt that bad. lots of regression testing tho

coming to a daily stand up near you
What did you think about today's newsletter? |