Workflow Automation: Nested For Each Loop

Nested For Each Loop

When collecting Items from multiple Apps, all Items are placed in their own respective App bucket. This means when you loop through the collected items, there is no direct way to determine the Child Item (App B) for the current looped Parent Item (App A). This can be solved with a Nested For Each Loop and a Sanity Check.

Nested For Each Loop 1


EXAMPLE

Collect all Projects from App A and the related Deliverables in App B and create a custom HTML table with data from both Items.

First, Get Referenced Items to collect all items from App A & App B.

Nested For Each Loop 2

Next, create a Custom Variable, prior to the For Each Loop, that will contain the start of the Custom HTML Table.

Nested For Each Loop 3

Start a For Each Loop for each of the collected items.

Add a Sanity Check to match the Deliverable to the current Project in the Loop.

Be sure to check that App A’s relationship field matches the title of App B.

Nested For Each Loop 4

Continue building the table Variable, close the For Each Loops and Sanity Check, and then close the HTML table outside of the loop. This Variable token can now be used in a rich text box.

Nested For Each Loop 5

Here is the result of the table placed in a PDF:

Nested For Each Loop 6

Workflow Automation: Nested For Each Loop