Restricted picklist value is throwing an error on creation of Case record from apex class

My case object has a custom picklist which has around 20 values. However the Labels and API names are different for each of the values. Also restrict picklist value checkbox is checked for the picklist field.

Now my requirement is to create a case in my apex class. However, whenever I provide API value of one of the picklist values as string, it is throwing the following error

Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field: Auto PCG: [U_Product__c ]

Apex code

 Case caseObject = new Case(Country__c = country,
                               U_Product__c = 'Auto PCG',
                               Type = caseType,
                               MDue_Date__c = dueDateValue,                                
                              );
 insert caseObject;

What am I doing wrong here? I will not be able to uncheck the restrict picklist values checkbox

Leave a Reply

Your email address will not be published. Required fields are marked *