I have 2 Orgs let's call them A & B. I have a process that queries org A and transfers data into Org B. For simplicity, let's say
After my upsert I end up with a record in Org B that looks like
OrgB.Id OrgB.Manager_r OrgA__c.Id OrgA__c.ManagerID
Sorry if thats not clear but basically a Contact in Org B has a lookup relationship to Contact object called Manager.
My problem is that lets say this is the first time the process runs. If I were to write a trigger say to update the managerID for a contact
select Id from Contact where OrgA.ID = :ManagerID
where ManagerID is the managerID for the Contact record that fired the trigger.
That Manager contact record may not exist yet until the entire trigger has run.
Now maybe the second time I run it, the manager ID would exist.
How could I wait until all records were created to then run a trigger?
Is a trigger even the right solution? Should this be a process builder process?
I am kind of learning as I go here, any advice would be awesome.