Skip to main content
Hello,

 

I am trying to update a lookup field on a child record with the ID of a child record that is related to the Parent but in a different object. My scenario:

 

I have an Opportunity Record (Parent). I have a custom object related to that Opportunity record (Child A). I also have a separate custom object related to the Opportunity record (Child B). When a record in Child B is created I want to update a Lookup field (lookup to Child A), with the ID from a record that was created in Child A. 
5 respuestas
  1. 6 jun 2017, 14:39
    Perfect explanation as it makes the entire picture crystal clear. OK so first of all, you don't need an Apex trigger for this and can easily accomplish using Process and Flows. This is what the design will look like:

     

    Process implementation

     

    1. Create a Process on the Child B object that fires when a record is created.

     

    2. Immediate action for Process: Launch Flow

     

    3. Pass the Opportunity ID, Project year and Child B record ID into the Flow variables.

     

    Flow implementation

     

    1. Perform a Record Lookup on Child A object where Opportunity ID and project year match what we passed via the Process earlier into Flow variables.

     

    2. Store this Child A's record ID in a Flow variable (varChildAID)

     

    3. Now perform a Record Update on Child B object where you update Child A lookup field with varChildAID

     

    Activate both and you should be good to go!

     

    PS: Remember that the flow and flow input variables must be created first to build this.