+ Start a Discussion
Force.platformForce.platform 

INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field error while testing

Hi All,
I have test class where i am trying to create record with mailing state which is picklist, i am passong same state value as defined in field definition , still getting error.
Any idea about this.

 
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

If that value is not added in the record type then you will get this error. OR, You are trying to enter a non-existing value to that pick-list field and restricted pick-list is enabled.

When creating these global picklists you have to go into the record type and edit the picklist and assign the picklist values to that record type.

Include the picklist values in the record type and deploy the field with record type as well. Also, check if that picklist value is there in that field.

Please refer to below link which might help you further.

https://help.salesforce.com/articleView?id=Unable-to-create-record-on-custom-object&language=en_US&type=1

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks and Regards,
Khan Anas