function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Freddie TateFreddie Tate 

Use a flow to copy 2 child levels objects to a target object

We have "Form" Custom Object that could be connected to a "Template" Custom Object
Each "Template" has child object "Component" and Each "Template Component" has child object "Template Component Question"
Each "Form" has child object "Form Component" and Each "Form Component" has child object "Form Component Question"

Once template is being chosenin a specific "Form", there is a flow that copies all the specific "Template" child objects to a "Form" Child Objects

Currently, the flow handle the copy of 1st level of child objects and it is working great

We need to also copy the next level of child objects - Questions.

Can you explain me how to adjust our current flow to make this happen ?

Thanks in advance

User-added image
Geoffrey BessereauGeoffrey Bessereau

This is harder than it looks like.

Basically you're going to have to abstract what the flow loops over, and maintain two different lists of records: one final, to update, and one "current", for the children of the record you are currently on.

The flow is going to end up looking like this:

User-added image
Where the highlighted assignment actuall adds the records to two lists (the final one, and the loop one), and the assignment above the second loop purges one list while passing the id of the record you want to search into the main loop.

So to recap:
- abstract your record id before the first lookup/loop combo
- add to two lists
- continuously increment one list while purging the other everytime you get to the higher level loop.