How to query Salesforce Picklist Field values using SOQL?

How to query Salesforce Picklist Field values using SOQL?

To query Salesforce Picklist Field values using SOQL, use PicklistValueInfo object/entity.

Sample Code:

EntityDefinition objED = [
    
	SELECT Id, DurableId
	FROM EntityDefinition
	WHERE DeveloperName = 'Account'
    
];

FieldDefinition objFD = [
    
	SELECT Id, DurableId
	FROM FieldDefinition
	WHERE EntityDefinitionId =: objED.DurableId
	AND QualifiedAPIName = 'Industry' 
    
];

List < PicklistValueInfo > listPVIs = [
    
	SELECT Id, Label, Value
	FROM PicklistValueInfo 
	WHERE EntityParticleId =: objFD.DurableId
	
];

for ( PicklistValueInfo objPVI : listPVIs ) {

	System.debug( objPVI.Label + ' - ' + objPVI.Value );	

}

Output:

Leave a Reply