How to Retrieve Picklist values in Lightning Web Component using JavaScript

Lightning, Lightning Web Components, Salesforce, Salesforce DX

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

Here is the complete code for your reference

2 comments

  • 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