How to get picklist values of Salesforce Standard object picklist field?

How to get picklist values of Salesforce Standard object picklist field?

Schema.DescribeFieldResult and Schema.PicklistEntry can be used to fetch picklist values of Salesforce Standard object picklist field.

Sample Apex Code:

Schema.DescribeFieldResult fieldResult = Account.Type.getDescribe();   
List < Schema.PicklistEntry > picklistEntries = fieldResult.getPicklistValues();   

for ( Schema.PicklistEntry objEntry : picklistEntries ) { 
    
    System.debug(
        objEntry.getLabel() + 
        ' - ' +
        objEntry.getValue()
    );     
    
} 

Leave a Reply