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
Sebastian PageSebastian Page 

How can be extract all picklist values Using apex

I have a requirment to fetch the details of a record type (case Object) and present in JSON.
Among other fields on the Record type, there are few dependent Picklist fields :
Ticket Category (Controlling Ticket Type)
Ticket Type (controlling Ticket Item)
Ticket Item
I am suppose to extract all the mappings of the picklists and fields on the record type page layout.

If some one have worked on a similar requirement, please suggest how this can be achieved.

Thanks and Regards
Sebastian Page
VinayVinay (Salesforce Developers) 
Hi Sebastian,

Try below snippet.
String objectName = 'Contact';
String fieldName ='LeadSource';
  
Schema.SObjectType s = Schema.getGlobalDescribe().get(objectName) ;
Schema.DescribeSObjectResult r = s.getDescribe() ;
Map<String,Schema.SObjectField> fields = r.fields.getMap() ;
Schema.DescribeFieldResult fieldResult = fields.get(fieldName).getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry pickListVal : ple){
    System.debug(pickListVal.getLabel() +' '+pickListVal.getValue());
}

https://developer.salesforce.com/blogs/developer-relations/2008/12/using-the-metadata-api-to-retrieve-picklist-values.html

Thanks,
Sebastian PageSebastian Page
Thanks Vinay, but problem is defferent. I want to extract all the mappings of the picklists and fields on the record type page layout.