function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Katta RahulKatta Rahul 

Field Integrity exception on MailingState(Contact Object)

Hi All,

We have changed the MailingState and MailingCountry fields to picklist from FreeText. So, I am trying to create a Contact record as a Portal User using Apex. I am getting the below error:

"System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, There's a problem with this state, even though it may appear correct. Please select a state from the list of valid states.: [MailingState]".

I have used the same State name for Account Object, It inserted the record. I am having this issue only with Contact record. I have given the Portal profile "read and create permissions on the Object(Contact and Account)" including all the fields. 

Can someone please help me out?

Thanks in Advance!!!!
AshlekhAshlekh
Hi,

I think Mailing state is depend on Mailing Cuntry so check the dependency  and check the value are enabled for picklist which you are providing value in that fields.
Katta RahulKatta Rahul
Hi Ashlekh,

Thanks for the reply.
I have given Mailing Country as 'United States'.
I am actually hard coding the values to test it, I am able to insert the account record with the same values and not able to insert the Contact record.