In my apex class and trigger code I have If statements based on picklist values. Using picklists in code I know uses the api name of the picklist value.
My question is, is it ok to just use the api name or is it better to create custom metadata? So if my picklist consists of 2 values for example:
Values | API Name
Old stuff | Old
New stuff | New
Is is good enough to just write the code like this:
If (act.status__c = 'Old'){
act.status = 'New';
}
which is basically hard-coding, which I don't like to do, even if it's using the API name. If I create custom metadata, I still end up checking actual values though so it doesn't seem better. Is there a better way to check and set picklist values in code?
I should mention that my picklist has many values - it's the Status for Orders and there are several for the 'Draft' option as well as for the 'Activated' option.