How to Retrieve Picklist values in Lightning Web Component using JavaScript

4
1543

Hi Folks,

In this Post, we will learn how we can get the picklist field values in our Lightning Web Component using JavaScript Controller. We do not need to write a single line of apex code.

We will utilize the inbuilt uiObjectInfoApi library provided by salesforce.

It contains all the required methods to get the information about picklist field values.

This Library has the following 3 methods which we are going to learn

  1. getPicklistValues Gives all the picklist values for the defined field. know More Here
  2. getPicklistValuesByRecordType Gives all the picklist values information related to a Recordtype for a Object. Know More here
  3. getObjectInfo gives you the complete information about the object. Know more here

Here is the video for the same

4 COMMENTS

  1. Hello Amit,
    I am trying to retrieve pick list values of a field in lightning component. Everything works fine, but the problem is I am able to see the picklist values in alphabetical or ascending order. I need to show them in the order as I defined when created that custom field. Any workaround for this. Any help will be greatly appreciated. Thanks in advance

LEAVE A REPLY

Please enter your comment!
Please enter your name here