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
SFDC@007.ax1656SFDC@007.ax1656 

Fetch picklist values through SOQL query?

1. Is it possible to fetch all the picklist field names along with the picklist field values available in Salesforce? Is there any object available in salesforce to query picklist values? Eg: Select Name From Picklist_Table ?
 
2. Using SOQL query is it possible to fetch the picklist values? instead of using getDescribe().getPicklistValues() through apex ?
danpeterdanpeter

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

 

Here are some ideas:

 

1)

Check out workbench for reporting on metadata:

http://wiki.developerforce.com/page/Workbench

 

2)

Custom SOAP metadata API to describe objects and look for picklists and get values.

 

3)

appexchange packages such as : https://appexchange.salesforce.com/listingDetail?listingId=a0N300000018leZEAQ

 

Thanks,


Dan

 

 

 

 

Fabien SchiettecatteFabien Schiettecatte
For future readers, here is how you can get picklist values with apex.
String objectName = 'Account';
String fieldName = 'CustomPicklist__c';

List<PicklistValue> picklistValueList = new List<PicklistValue>();
Schema.SObjectType sObjectType = Schema.getGlobalDescribe().get(objectName);
Schema.DescribeSObjectResult describeSObjectResult = sObjectType.getDescribe();
Map<String, Schema.SObjectField> sObjectFieldMapById = describeSObjectResult.fields.getMap();
List<Schema.PicklistEntry> picklistEntryList = ObjectFieldMapById.get(fieldName).getDescribe().getPickListValues();