I am facing a weird issue during production deployment.

I have created a picklist field (which is not exist in Production) Lead_Assignment_Status__c which is by-default restricted and values are New and Assigned. This picklist is not mandatory field.

Lead Assignment Status

In the testSetup method, created lead records as follows and updated Lead_Assignment_Status__c = 'Assigned':

Lead objLead = new Lead();
        objLead.RecordTypeId = 'xxxx';
        objLead.Company = 'Test';
        objLead.FirstName = 'f1';
        objLead.LastName = 'l1';
        objLead.Lead_Stage__c = 'New';
        objLead.Status ='New';
        objLead.LeadSource ='External Referral';
        objLead.Email ='test@gmail.com';
        objLead.IsConverted = false;
        objLead.OwnerId = UserId; 
insert objLead;

//updates Lead with Assigned Status
       objLead.Lead_Assignment_Status__c = 'Assigned'; 
       update objLead; 

During deployment this code snippet is failing with this error at this line update objLead;:

System.DmlException: Update failed. First exception on row 0 with id 00Q16000018n8DREAY; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field: Assigned: [Lead_Assignment_Status__c]

When I run this test class at our development environment it is running without any errors.

My question is why this is failing during deployment.

  • Do the picklist values exist in production already? – sfdcJameson Nov 18 '16 at 21:21
  • no, its a new field – Santanu Boral Nov 18 '16 at 21:23
  • Try creating that field in Production and setting the picklist values before deploying and see if that fixes the issue. – sfdcJameson Nov 18 '16 at 21:25
  • best information I've been able to find is a link to a blog: opfocus.com/… . I didn't find anything specific in the Winter '17 release notes (and restricted picklists went GA in summer '16). Perhaps it's worth calling into Salesforce support. – Derek F Nov 18 '16 at 21:33
  • you are correct – Santanu Boral Nov 18 '16 at 21:33

I have created this field in production prior to deploying test classes and it has been successfully deployed.

Thanks to sfdcJameson

|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.