You need to sign in to do that
Don't have an account?

Apex class tests failing on picklist state and country
I have several apex class tests that are failing because we switched our state and country address fields to picklists. I tried to correct it in the code but am still getting the same error:
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, There's a problem with this country, even though it may appear correct. Please select a country from the list of valid countries.: [BillingCountry]
Stack Trace: Class.Z_PaymentMethodCaptureControllerTest.createTestAccount: line 276, column 1 Class.Z_PaymentMethodCaptureControllerTest.testAppendMessages: line 185, column 1
When creating the account as part of the test, I code it to input United States, a value in our picklist field for BillingCountry.
Tried to research answers but am coming up dry. Any help out there?
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, There's a problem with this country, even though it may appear correct. Please select a country from the list of valid countries.: [BillingCountry]
Stack Trace: Class.Z_PaymentMethodCaptureControllerTest.createTestAccount: line 276, column 1 Class.Z_PaymentMethodCaptureControllerTest.testAppendMessages: line 185, column 1
When creating the account as part of the test, I code it to input United States, a value in our picklist field for BillingCountry.
Tried to research answers but am coming up dry. Any help out there?
Please try the below code,
BillingCountrycode = 'US';
Thanks,
Vinoth
All Answers
When you use State and Country picklists the value will appear as 'United States' in the UI, but the actual value is 'US'.
That didn't work either unfortunately. I got back the same error. Any other thoughts?
Please try the below code,
BillingCountrycode = 'US';
Thanks,
Vinoth
That was perfect. Thank you sooooo much!
James