Dynamically Fetch Picklist Values Based On Record Type In Salesforce LWC

Lightning Web Component

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.

lwc record type picklist

So let’s start with HTML file of our LWC component.

Step 1 : LWC HTML file [FetchPicklistFromLDS.html]

Check also : Dynamically fetch picklist values from object In Lightning Web Component using apex
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]

Output : 

lwc record type picklist

Related Resources :
Other popular Post :

Follow us for new post updates. & Don’t forget to bookmark this site for your future reference.

Facebook : https://www.facebook.com/sfdcmonkey/

Instagram : https://www.instagram.com/sfdc_monkey/

(Visited 875 times, 1 visits today)

Leave a Reply