In a test class, I'm passing a value of a restricted picklist. Below is the value, and the screenshot of the restricted picklist LOVs:-

SVMXC__Quote_Line__c testQuoteLine = new SVMXC__Quote_Line__c();
testQuoteLine.ESMX_Maintenance_Window__c='SWE Reg – Regular Labour, Semi-Weekend (e.g. Saturday)';

enter image description here

Even though, as it can be seen, we are passing the correct value, we are getting the below error while running the test class:-

System.DmlException: Update failed. First exception on row 0 with id a34g0000000v3ceAAA; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Maintenance Window: bad value for restricted picklist field: SWE Reg – Regular Labour, Semi-Weekend (e.g. Saturday): [ESMX_Maintenance_Window__c]

N.B.: No record type or Field dependency issue faced here.


probably the value you want to enter isnt exposed to the record type.

  1. go to the object`s record type
  2. select the relevant one
  3. select the relevant "picklists Available for Editing" for edit
  4. add the values

Since, picklist values have been stored as API Name (in the database), so you need to assign the API Name of the picklist item.

SVMXC__Quote_Line__c testQuoteLine = new SVMXC__Quote_Line__c();
testQuoteLine.ESMX_Maintenance_Window__c='SWE Reg';

In the UI, it will be displayed as value [SWE Reg – Regular Labour, Semi-Weekend (e.g. Saturday)]

  • Hi Santanu, Thank you for the response. However, even providing the API name, I'm encountering the same issue. – Abhijeet Mitra Aug 16 '18 at 11:42
  • Is that script is getting run by a specific user? Do you have any recordtype? – Santanu Boral Aug 16 '18 at 11:49
  • As mentioned, there is no record type restriction. Also the script is not being run by any user. The FLS is set to the user which I'm logged in. – Abhijeet Mitra Aug 16 '18 at 11:54
  • check that any space is there in the API Name, Also, suggest you to create a record from UI and check how it is storing as SVMXC__Quote_Line__c's record and replicate same data in test class – Santanu Boral Aug 16 '18 at 11:59
  • Have you specified default value on picklist field? Please check this link help.salesforce.com/…. – Pragati Jain Aug 16 '18 at 13:56

I ran into this same issue and it turned out that I didn't have the correct field dependency set. If you're also using Field Dependencies, check to ensure the value in question is enabled for the correct controlling field values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.