You need to sign in to do that
Don't have an account?
Apex Field Describe - Get color value for PicklistEntry
Hi - I am trying to get the color value associated with a PicklistEntry. I've written some logic that gets the PicklistEntry, but I am not sure if there is a way to get the color associated with that entry using the Apex field describe methods. Can someone help me out or confirm that this isn't possible? (It looks like it is part of the metadata API, but I can't find any documentation on using it in Apex.)
Map<String, Schema.SObjectType> globalDescribe = Schema.getGlobalDescribe();
Map<String, Schema.SObjectField> objectFields = globalDescribe.get('Campaign').fields.getMap();
Schema.DescribeFieldResult fieldInfo = objectFields.get('Type');
if(fieldInfo.getType() == 'Picklist' || fieldInfo.getType() == 'MultiPicklist') {
for(Schema.PicklistEntry pe : fieldInfo.getPicklistValues()) {
// Instead of getValue(), is there a getColor() method? pe.getValue();
}
}
Unless I've been totally missing something, there isnt anyway to associate a picklist value, nor even the picklist itself (or any other field for that matter) with a color. The color that something is displayed as in the standard sf page is determined by the "tab style" that you choose for the entire tab that is associated with the object.
I am also trying to apply a color code to different leads based on lead type, industry, and/or record type, but sounds like this is not currently possible. If you could please confirm, that would be great.