How to query 'Value' of a picklist rather than the 'API NAME', using SOQL?

You can use toLabel() to convert the picklist api name to a label:

SELECT toLabel(CUSTOM_PICK_LIST_COL__C) FROM OPPORTUNITY


You don't need to use SOQL to do this, instead you can get it using Apex's Schema utility and DescribeFieldResult class. For example:

public List<String> myPicklist {
  get {
    if (myPicklist == null) {

      myPicklist = new List<String>();
      Schema.DescribeFieldResult field = Object__c.MyPicklist__c.getDescribe();

      for (Schema.PicklistEntry f : field.getPicklistValues())
        myPicklist.add(f.getLabel());

    }

    return myPicklist;          
  }
  set;
}

This just returns a List<String> of labels of the field MyPicklist__c in object Object__c.

You might want to review what you can do with that class here.

Bonus: you don't use any SOQL and contribute to limits.

Tags:

Soql

Picklist