FIELD_INTEGRITY_EXCEPTION in Salesforce: what it means and how to fix it

Short answer: FIELD_INTEGRITY_EXCEPTION means a value failed one of Salesforce's built-in integrity checks rather than a rule an admin wrote. During data loads it usually points at address fields under State and Country Picklists: a country Salesforce doesn't recognize, a state that doesn't belong to the chosen country, or a state sent without a country.

Some rules are built into Salesforce itself rather than written by an admin: a state has to belong to its country, related records have to agree with each other, certain fields can't be zero. When a value breaks one of those platform checks, the save is refused with FIELD_INTEGRITY_EXCEPTION and a message describing the check. A typical example from an address load:

FIELD_INTEGRITY_EXCEPTION: There's a problem with this country, even though it may appear correct. Please select a country/territory from the list of valid countries.: Billing Country

The code is broad, so the message text matters more than usual. It tells you which check fired and, at the end, which field it was attached to.

Why it happens

  • Country values the org doesn't recognize. With State and Country Picklists enabled, free-text countries such as "USA" or "U.S.A." no longer pass unless they match a configured country.
  • States that don't belong to the country. A state code is valid only for its own country. Combining a valid country with a state from somewhere else fails, as does a state with no country at all.
  • Text and code fields sent together. Loading both BillingCountry and BillingCountryCode with values that disagree gives Salesforce two answers for the same address.
  • Countries missing from the target org. Orgs maintain their own country and state lists. A record that is valid in one org can fail in another where that country or state isn't active.
  • Other platform checks. The same code reports problems such as nonzero-only numeric fields and price book entries that don't match the parent record.

How to fix it

  1. Read the full message. Identify the check and the field named at the end before changing anything.
  2. Load codes, not names. Map countries and states to ISO codes and write the ...CountryCode and ...StateCode fields. Leave the text address fields blank.
  3. Validate pairs before loading. Check each state against the list of states for its country, and drop or fix rows where they disagree.
  4. Compare configuration. In Setup, open State and Country/Territory Picklists in both orgs and make sure the countries and states your data uses are active in the target.
  5. For non-address messages, fix the specific relationship the message describes, for example by choosing a price book entry from the price book the parent already uses.

How Syntharil handles it

Syntharil labels FIELD_INTEGRITY_EXCEPTION a schema or configuration error. One exception comes from how its classifier works: message patterns are checked before codes, and a message containing "value outside of valid range" is labelled data format whatever its code, so an integrity error carrying that text would be grouped with the numeric range errors. For seeding, Syntharil leaves out the text address fields when their code counterparts exist, pairs state code fields with their country code fields, and omits the state when the chosen country has no valid states in the org. Anything that still fails is reported per row with Salesforce's message.

FAQ

Is FIELD_INTEGRITY_EXCEPTION caused by a validation rule?

No. Validation rules and Apex addError() calls produce FIELD_CUSTOM_VALIDATION_EXCEPTION. FIELD_INTEGRITY_EXCEPTION comes from checks Salesforce enforces itself, so there's no admin rule to deactivate. The fix is in the data or in the org's configuration, such as its list of countries and states.

Why does FIELD_INTEGRITY_EXCEPTION reject a country that looks correct?

With State and Country Picklists enabled, the value must match one of the org's configured countries exactly. A spelling variant, an unexpected abbreviation, stray whitespace, or a country that isn't active in this org makes Salesforce reject a value that reads fine to a person.

Should I send BillingCountry or BillingCountryCode when State and Country Picklists are on?

Send the code fields, such as BillingCountryCode and BillingStateCode, and leave the text fields empty. Salesforce fills the text fields from the codes. Sending both risks a mismatch between them, which FIELD_INTEGRITY_EXCEPTION reports.

Can a state code from another country trigger FIELD_INTEGRITY_EXCEPTION?

Yes. State codes are only valid under their own country. A code that exists for one country but not for the country on the record fails with a message saying the value isn't an available state, even though the code itself is in the org's list.

Does FIELD_INTEGRITY_EXCEPTION appear outside address fields?

It does. The same code covers other built-in consistency checks, such as numeric fields that must be nonzero or line items whose price book entry doesn't match the parent's price book. Read the message text, since it names the specific check that failed.

All Salesforce errors →

Try Syntharil free