- 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? |