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
EclipseTalkEclipseTalk 

What is the best way to update Contact list

Hi,

For instance I create a new Account and I need to update its list of Contacts. What if the best way?

Is the line below correct? Thank you

 

anAccount.getContacts().getValue().getRecords().add(aContact);

Best Answer chosen by Admin (Salesforce Developers) 
LosintikfosLosintikfos

preety simple:

 

Every account is mapped to contact with AccountId. Therefore to update list of contact for 'A' Account, you'll have to fetch all contacts belonging to the account and using UpdateDocument(soap), and then update each contact instance.

 

Simples.