I want to get label of picklist from soql and use it in my apex code to do some logic. For example following code gives me error

Compile failure on line 7, column 18: Invalid field labelType for SObject FieldSet__c

In below code how do I get the label for picklist in my apex code.Thanks for your help and time.

List<FieldSet__c> fieldSets = [SELECT toLabel(Type__c) labelType,Type__c
FROM FieldSet__c];

for (FieldSet__c fieldSet : fieldSets) 

1 Answer 1


You can access it by sobject get method like: fieldSet.get('labelType') and you can select both label and picklistvalue in single query.


You must log in to answer this question.

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