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
Connor CainConnor Cain 

updating records in a list where the field comes from the parent Object

We have run into an interesting problem; we are creating a table of AccountContactRelations for the users to edit fields from the account, Contact, and Account Contact relation for mulitple accounts they are assigned. 

here is our Query:
List<AccountContactRelation> a = [SELECT id, AccountId, Account.Name, Contact.LastName, Roles FROM AccountContactRelation]

We display these to the user for them to quickly edit, but the issue comes when we need to save the records. how would we be able to save Account.Name and Contact.LastName?
WEN JIEWEN JIE
Hi Connor,

Based on your description, you need to get corresponiding account and contact obj data, then update them. Since you already have Account.Id or Contact.Id.

Thanks