0

I have some trouble with Global-Picklist fields and Unit Test after Deployment via Chnage Set in another ORG.

I have a couple of Custom Fields and a Global Picklist field on Case object. I have written a Trigger on Case to populate a Description field based on the Picklist value selected and other Custom field entries. Everything works fine in my DevORG-A with Unit test and Code Coverage 100%.

But when I was trying to deploy the Global Picklist & its values from one Devorg-A to Devorg-B using ChangeSet the Unit Test having trouble. I am able to validate and Deploy with Default options, but whenever I try to 'Run All' Tests for checking Code Coverage in Devorg-B its failing.

Error "System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field: Apple IPhone: [ProductList_Consumer__c]"

  • [ProductList_Consumer__c] --> Picklist

  • Apple IPhone --> Is the value I used in test class while creating a Case.

I was sure that I used the correct Picklist Value in my Unit Test class for creation as we have a restriction of values and I also i checked the Record Types and its values are available.

I googled and can see some restrictions around Global Picklist as it recently released only. Can you please provide me some workaround for the above to deploy the Global Picklist values from one Dev ORG to Sandbox/Prod?

Thanks in Advance

  • Is "Restrict picklist to the values defined in the value set." set to true on your ProductList_Consumer__c picklist field ? – Oleksandr Berehovskyi Jun 7 '17 at 6:40
  • Yes, since its Global Picklist its set Automatically and no way to remove the flag as well. – Robert Thomas Jun 7 '17 at 7:17
1

I received this error earlier today & was able to resolve it by adding all the related Record Types to my Change Set.

So in your situation, I believe adding all the Case Record Types to your Change Set may have resolved your problem.

| improve this answer | |
0

I found a workaround to Pass the TestClass. By Deleting the Global Picklist after commenting the Field usage in Trigger & Testclass and then later recreating the Global Picklist and using it in Trigger & TestClass.

But not sure about why the Global Picklist have trouble in Deployment after moving it from one ORG to another.

| improve this answer | |

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.