function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

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.


Picklist values can have a color associated with them (this is used for charts/dashboards). There does not appear to be a way to programmatically access this information in Apex Code as of yet.

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.



Don Barnes 5Don Barnes 5
Is this still the case, after all these years, that you can't programatically access the color values in a picklist?  If so I disappointed!  Not surprised, just disappointed.