I would like to get label of stored picklist value. Is there any straight forward way of doing that or I have to loop through all picklist values?
Attribution to: doga
Possible Suggestion/Solution #1
You may Use Custom settings to store the Labels if you think looping may bring issues.Have a custom Setting with api name and label and you may use custom setting methods to retrieve only for those you want.
Map mapCodes = ISO_Country__c.getAll();
// display the ISO code for Afghanistan
System.debug(‘ISO Code: ‘+mapCodes.get(‘AFGHANISTAN’).ISO_Code__c);
Attribution to: Mohith Shrivastava
Possible Suggestion/Solution #2
For picklist values you can use the toLabel() function in soql to retreive the label, e.g.
select select id,name, toLabel(Industry) from account
Otherwise you can call describeSobject and get the label from the returned picklistValue structure.
Attribution to: superfell
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4482