[SalesForce] Get a list of Pick List Values

Via the SOAP API, can I get a list of the Pick List values from an Objects Field's type that is a pick list?

For example,

The Object Opportunity has a field called Type which is a Picklist. I would like to be able to query this Pick List. Is is possible?

Best Answer

Yes, you can. There is a method called describeSObjects() which can be used to retrieve picklist values.

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_describesobjects.htm

A code example is also provided there. Here an excerpt:

        // Determine whether this is a picklist field
        if (field.getType() == FieldType.picklist)
        {                            
            // Determine whether there are picklist values
            PicklistEntry[] picklistValues = field.getPicklistValues();
            if (picklistValues != null && picklistValues[0] != null)
            {
                System.out.println("\t\tPicklist values = ");
                for (int k = 0; k < picklistValues.length; k++)
                {
                    System.out.println("\t\t\tItem: " + picklistValues[k].getLabel());
                }
            }
        }
Related Topic