+ Start a Discussion
Jose ZunigaJose Zuniga 

Relationship between a User account and a Person account

My JIT code creates one User object  u  and another Person Account object with  accountId  ID. (my environment uses person accounts). I need to establish a relationship between them and I believe this has to be done using a command like:

u.ContactId = [select PersonContactId FROM account where ID =: accountId].Id

However, I am getting the next error at the insert command:

10:34:29:496 FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Contact ID: id value of incorrect type: 0015500000Es8udAAB: [ContactId]

Can someone please tell me what am I missing?
Thanks Jose
Best Answer chosen by Jose Zuniga
Jose ZunigaJose Zuniga
As sugested by a uy called  Vigneshwaran G at the stack exchange forum I modified the command to

u.ContactId = [select PersonContactId  FROM account where ID =: accountId].PersonContactId;

and the error ended