+ 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?
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.