[SalesForce] How to use Tooling API to get available values from picklist

How would one get the values available values of a System Custom Field?

Here are the details of the "System Custom Field":

Field Label: "Working Status"

Field Name: "Working_Status"

API Name: Working_Status__c

Object Name: "System"

Data Type: "Picklist"

Values: { "Running", "Starting Up", "Unknown"}

I am using the following query:

SELECT Values FROM CustomField WHERE ObjectName = 'System.Working_Status__c'

However, this is not working. I can use the describe the Lightning Platform REST API describe method of doing this, but it returns every possibility in the system.
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_describe.htm

What do I need to change in my SOQL query to make this happen?

Best Answer

It's worth noting you don't need any API calls at all to get this information, and can simply use the field describe (which is also accessible via REST API).

List<PicklistEntry> entries = System.Working_Status__c.getDescribe().getPicklistValues();

List<String> values = new List<String>();
for (PicklistEntry entry : entries)
{
    values.add(entry.getValue());
}
Related Topic