I have a record type picklist on Case object. When I create case via email-to-case that works fine without any issue(I have some APEX code related to that)
Issue: The problem is when I write test cases for that and run the test that says on insert and update.
DEBUG|Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field
What is the issue? Even though that works fine when I create case via email-to-case.
Case newCase = new Case(); newCase.Origin = 'Email'; newCase.Subject = 'Subject'; newCase.OwnerId = System.Label.Default_Case_Owner_Queue; newCase.Status = 'New'; newCase.Priority = 'Medium'; newCase.Description = 'This is a new case'; newCase.Type = 'Invoicing'; newCase.Email__c = 'email@example.com'; newCase.Close_Code__c = 'test'; // this is the picklist which is causing issue, the picklist value was already added to record type. insert newCase;
How can I fix that to pass the tests? TIA