You need to sign in to do that
Don't have an account?
Mohit Gupta 125
Get all picklist values using SOQL
I want to pick all values of a particular field which is a 'PickList' (say the field name is ABC)
I tried using the below query which this field is part of (say XYZ).
My query is
Select toLabel(ABC) FROM XYZ
But this is only giving me those Picklist values which are part of XYZ/ or selected at least in one of the XYZ item.
I want the entire master list of PickList values of ABC.
How can I do it using SOQL?
Thanks
All Answers
If you want to display picklist values in your custom page through dynamic apex.Y ou can check below link it will help.
https://developer.salesforce.com/blogs/developer-relations/2008/12/using-the-metadata-api-to-retrieve-picklist-values.html
Below code can fulfill your requirements. Hope this will work for you.
public List<String> getPickListValuesIntoList(){
List<String> pickListValuesList= new List<String>();
Schema.DescribeFieldResult fieldResult = ObjectApiName.FieldApiName.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry pickListVal : ple){
pickListValuesList.add(pickListVal.getLabel());
}
return pickListValuesList;
}
Please mark this as best answer if this solves your problem.
Thank you
Ajay Dubedi