Apex utility class for working with Picklists with built-in cache.
Click this link to install the PicklistUtils unlocked package in your org.
Reference:
- Working without record types
- Working with object and field references
- Working with object and field names as strings
- Working with record types
- Working with case statuses
List<Schema.PicklistEntry> getPicklistValues(
sObjectType sObjectType,
Schema.sObjectField field
)
Example:
List<Schema.PicklistEntry> entries = PicklistUtils.getPicklistValues(
Account.sObjectType,
Account.Industry
);
List<Schema.PicklistEntry> getPicklistValues(
String objectName,
String fieldName
)
Example:
List<Schema.PicklistEntry> entries = PicklistUtils.getPicklistValues(
'Account',
'Industry'
);
PicklistEntries getPicklistValues(
String objectName,
Id recordTypeId,
String fieldName
)
Example:
PicklistUtils.PicklistEntries entries = PicklistUtils.getPicklistValues(
'CustomerRequest__c',
'0124H000000cz6R',
'Priority__c'
);
List<CaseStatus> getCaseStatusValues(
Boolean isCaseClosed
)
Example:
List<CaseStatus> values = PicklistUtils.getCaseStatusValues(
true
);