Ads

Dynamically Fetch Picklist Values Based On Record Type In Salesforce LWC

Dynamically Fetch Picklist Values Based On Record Type In Salesforce LWC


Hey guys, today in this post we are going to learn that how we can display picklist values based on record type in salesforce lightning web component. It’s has been always a challenging part to display picklist values based on record types in aura components. But now in LWC, with the help of ‘getPicklistValuesByRecordType‘ and ‘getObjectInfo‘ imported functions , we can easily display it.
So let’s start with HTML file of our LWC component.
Step 1 : LWC HTML file [FetchPicklistFromLDS.html]
LWC JavaScript file [FetchPicklistFromLDS.js]
  • Picklist values are scoped to a record type. getPicklistValuesByRecordType function returns a collection of picklist values for all the picklists of a specified record type. For more information, see Build UI for Picklists.
  • We are using ‘lightning/uiObjectInfoApi’ funtion to get object metadata, and get picklist values.
  • Check code comments.
LWC meta XML file [FetchPicklistFromLDS.js-meta.xml]

No comments:

Post a Comment