Option 1:- Please create cross object formula field on Contact object Option 2:- Your can create trigger on Account object to update all child Contact Sample Trigger for you
trigger AccountTrigger on Account ( after insert, after update )
{
Set<String> setAccountID = new Set<String>();
For(Account acc: trigger.New)
{
setAccountID.add(acc.id);
}
List<Account> listAccount =[select id,name, (Select, firstName, LastName fromm Contacts) from account where id in :setAccountID ];
For( Account acc: listAccount )
{
System.debug('----------->'+acc.Name);
List<Contact> lstContact = acc.Contacts;
for(Contact cont : lstContact)
{
System.debug('----------->'+cont.firstName);
// Add all your logic here
}
}
}
You can do this by using two ways based on your requirement.
- By usgin cross object formula field on Contact object. (contact field will be read only bcz of formula field)
- By using trigger. Write trigger on Account object and update the child records.
Let me know if you need more information on any of this option.Option 1:- Please create cross object formula field on Contact object
Option 2:- Your can create trigger on Account object to update all child Contact
Sample Trigger for you Please let us know if this will help you
You can update all child records based on parent record update.
https://developer.salesforce.com/trailhead/business_process_automation/process_builder