In this scenario our business requirement is that when an Accounts address is updated we need to update all the addresses of the related grandchildren Contact with the same data.
We will not sync the children Accounts for simplicity sake.
North52 BPA Solution
The North52 BPA solution works like this:
- We create a formula on the Account entity that triggers whenever the address1 fields change
- The formula retrieves all the children Accounts associated with this parent Account via the parentaccountid field on the Account entity
- The formula then retrieves all the children Accounts children Contacts (so the grandchildren of the original Account) associated via the parentcustomerid field on the Contact entity
- It will then loop over all the Contacts and update the address information with that of the grandparent Account
The following set of steps assumes you are just using the out of the box Dynamics 365 setup. But its easy to enhance if you have extra fields/requirements.
- Create a new formula, setting the following values in the Formula Guide:
- Source Entity set to Account
- Set Formula Type to Save - Perform Action
- Select the Classic editor
- Click Create
- Change the Name of the formula to Sync an Accounts Address with its grandchildren Contacts
- Set the Event field to Update
- Expand Source & Target and set the Source Entity Property to address1_line1, address1_line2, address1_line3, address1_city, address1_postalcode, address1_country
- Hold down control key to multi-select
- Copy and paste the following formula into the formula editor pane:
Iftrue(DoesNotContainData([account.parentaccountid] ), ForEachRecord( FindRecords('account', 'parentaccountid', [account.accountid], 'accountid'), ForEachRecordNested( FindRecords('contact', 'parentcustomerid', currentrecord('accountid'), 'contactid'), UpdateRecord('contact', CurrentRecordnested('contactid'), SetAttribute('address1_line1', [account.address1_line1]), SetAttribute('address1_line2', [account.address1_line2]), SetAttribute('address1_line3', [account.address1_line3]), SetAttribute('address1_city', [account.address1_city]), SetAttribute('address1_postalcode', [account.address1_postalcode]), SetAttribute('address1_country', [account.address1_country])))))
- Click Save
- You are ready to test
To test this formula, open an Account record that has child Accounts which have Contacts (Account > children Accounts > grandchildren Contacts).
Update the grandparent Account address fields and you will see the update occur in the grandchildren Contact.