Last active
April 21, 2019 20:33
-
-
Save Nahumancer/69c03bbaf45c5c86090a2c70b1cee845 to your computer and use it in GitHub Desktop.
Get picklist valid values.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String[] getValidPicklistValues(String object_name, String field_name) { | |
String[] values = new String[]{}; | |
String[] types = new String[]{object_name}; | |
Schema.DescribeSobjectResult[] results = Schema.describeSObjects(types); | |
for(Schema.DescribeSobjectResult res : results) { | |
for (Schema.PicklistEntry entry : res.fields.getMap().get(field_name).getDescribe().getPicklistValues()) { | |
if (entry.isActive()) {values.add(entry.getValue());} | |
} | |
} | |
return values; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment