function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
yajivyajiv 

return picklist using REST API

Hi,

 

How do I return a picklist of values from an Entity via REST API call?

 

Here is how I do this in Apex code:

 

Caller code:

 

xxxxHelper.getSelectOptions(Account.Question1__pc.getDescribe());


Called code:

 

public static List<SelectOption> getSelectOptions(Schema.DescribeFieldResult fieldResult) {

List<SelectOption> options = new List<SelectOption>();

for (Schema.PickListEntry ple : fieldResult.getPickListValues()) {

options.add(new SelectOption(ple.getLabel(), ple.getValue()));

}

return options;

}

 

 

I do see an equivalent  /Account/describe but I am not sure how to map it into the call above to get the PickList values ?

 

TIA,

Vijay

Best Answer chosen by Admin (Salesforce Developers) 
dkadordkador

The describe result has a collection of fields.  Find the field you want in that collection, then see if there's a "picklistValues" collection under that.