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
Assigned. This picklist is not mandatory field.
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 ='email@example.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
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.