I am using a .NET library - SalesforceMagic - for communication with SalesForce. I use a SalesForce API user credentials and pass data to and from via a SOQL query. It all works fine.

Now, there are many fields, which have specific picklist values assigned to them on the SalesForce side. Currently, I have hard-coded them into the UI, these values may however be changed by someone managing the object's field definitions in SalesForce.

Is it possible to retrieve these lists (for any specific field) via SOQL? If not, what would be the best workaround?

  • Can you add anything to the Salesforce org or does your client have to work with any org and so only use the standard platform APIs? If you are prepared to wait or contribute see github.com/clamidity/SalesforceMagic/issues/15. Or you can generate code from the metadata API WSDL.
    – Keith C
    May 26, 2015 at 16:45
  • For this part of the client, I can add anything (new objects etc) to the SalesForce instance. Makes me wonder whether there could be a workaround via adding a new custom object that lists some metadata, e.g. contains the picklist values for? Nevertheless, I can go with the WSDL way as well.
    – cccec
    May 29, 2015 at 9:57
  • I'd be tempted to do the list custom setting route. List custom settings can be queried just like standard custom objects can. So if you transfer the metadata into a list custom setting within the org you can continue to use only SalesforceMagic to access the data. You can write an Apex class to populate the list custom setting - see other answers for the sort of code you might use. You could just execute that code from the developer console when you know the picklist values have changed or you could schedule the code to run every night.
    – Keith C
    May 29, 2015 at 10:10

3 Answers 3


I m not sure if the SalesforceMagic library supports it or not, but if you use the standard enterprise api, you should be able to use the describeSObjects method to get the picklist field values.

here's a reference to the method which has sample code for java & .net clients.

  • Thank you! I had hoped I could avoid the heavy SOAP / WSDL method with this thin client, but it definitely is a workaround
    – cccec
    May 29, 2015 at 9:58
Schema.DescribeFieldResult fieldResult = ObjectAPIname.fieldAPIName.getDescribe();
List<Schema.PicklistEntry> plv = fieldResult.getPicklistValues();

for( Schema.PicklistEntry f : plv)
       System.debug('Field Label ' + f.getLabel());
       System.debug('Field Value ' + f.getValue());

Replace "ObjectAPIname" & "fieldAPIName" with your object & picklist field name respectively and you can get picklist values.

Hope this may help.

  • You've answered with Apex code which would be the correct way to do it in Salesforce, however the OP stated he is using a .NET library, and so this answer is not useable to her/him.
    – dBeltowski
    May 26, 2015 at 14:24
  • @DougB I think you need to read his question again. Nebula just elaborated on the accepted answer. No reason to downvote.
    – maguy
    Mar 24, 2016 at 19:23

I don't think you can access picklist values through SOQL.

Here is a code snippet taking Account object as an example.

Schema.DescribeFieldResult F = Account.Industry.getDescribe();    
List<Schema.PicklistEntry> P = F.getPicklistValues();

Hope this helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .