I am trying to cascade the same ownerid across all contact owners within an Account Contact Relation hierarchy. I wrote a pretty basic after update trigger on an account to accomplish this.

When all records are owned by the same person, it updates correctly. When there is a mix of ownerids, I receive "INVALID_FIELD, All accounts must have the same current owner and new owner.: [OwnerId]" Please note: Person accounts are enabled in this Org.

Basic Logic

 list<contact> Contacts = new list<contact>();
    for(AccountContactRelation r: [select id, 
                                   from AccountContactRelation 
                                   where AccountID in: AccountOwnerMap.keyset() 
                                      system.debug('r: ' + r);
                                      if(r.AccountID!=null && AccountOwnerMap.containskey(r.AccountID)){
                                          Contact c = new Contact(id=r.Contactid);
                                          c.ownerid = AccountOwnerMap.get(r.AccountID);
    system.debug('Contacts: ' + Contacts);
    //Update Contacts
        update Contacts;

Similar issue with no clear answers below.

  • I am facing same issue, did you find any solution for this? May 9, 2019 at 7:49

1 Answer 1


You can call the update from within a future method to fix this problem

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .