This is my Pseudocode
Trigger on Territory2 before Update
If IsChanged (UserTerritory2Association.User)
Get AccountID of the Account assigned to the Territory from ObjectTerritory2Association
Get UserId of the Territory's Assigned Owner from UserTerritory2Association
Fetch Child Records related to the AccountID from Account
Add the Child Records to a List
For EachItem in the ChildRecordList Get the ownerid
childrecordOwnerid = Territory's new Assigned OwnerID
Problem Definition:
There is a a self relationship on Account object
Parent Record: Account 1, RecordType = HQ Parent
Child Record: Account 2, RecordType = Billing Account
Child Record: Account 3, RecordType = Billing Account
On Account2, and Account 3 I have a field called Parent that looks up to Account 1
So basically I want to update the owner on the child records to be the user who is assigned to a Territory in the Territory Model.
The child records don't have a direct relationship with Territory2.
Since there is an additional relationship involved, Is this possible in a trigger or a flow ?
Edit
Added relationship diagram
If Assigned User in Territory2 is updated from 'David Yee' to 'Fred Smith' , All the Billing Accounts should be updated to 'Fred Smith'
Can i create a flow or trigger on the Territory2 Object such that when the assigned owner is updated, the owners on the Billing Account are updated. The owner on the HQ Account will be the same.