Salesforce System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, A country/territory must be specified before specifying a state value for field

Salesforce System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, A country/territory must be specified before specifying a state value for field:

This exception occurs when State is specified and Country is not specified. The following code can be used to regenerate the error.
Account objAcc = new Account();
objAcc.Name = 'Testing Account';
//objAcc.BillingCountry = 'United States';
objAcc.BillingState = 'Washington';
objAcc.BillingPostalCode = '54321';
insert objAcc;


To resolve, uncomment line objAcc.BillingCountry = 'United States';

No comments:

Post a Comment