Skip to main content

Loops

A loop repeats a section of your Wrkflow for each item in a list or each step in a numeric range. On Wrk, every loop is controlled by two Wrk Actions working together:

  1. Loop Through … — starts or continues a loop and emits a Loop ID plus the current item or index
  2. Continue Loop — tells the platform whether to fetch the next item or exit the loop for that Loop ID

Rule of thumb: each loop needs its own Continue Loop, wired back to the loop Wrk Action so you can pass the Continue Loop ID into the loop configuration.

Simple loop through a JSON array

The template below is a minimal example: it loops through [1, 2, 3], sends each value to Launch Console, then exits when the array is finished.

How to use the template

  1. Click Copy template above.
  2. Open your Wrkflow in the Wrkflow Designer.
  3. Paste with Ctrl + V (Windows) or Cmd + V (Mac).

The Wrk Actions appear on your canvas exactly as shown. The Designer assigns fresh IDs on paste, so you can paste the template as many times as you like.

What each Wrk Action does

Wrk ActionRole
Loop through JSON array (WA-1)Iterates over the JSON array [1, 2, 3] and outputs the current Item value plus a Loop ID
Send to Launch Console (WA-3)Logs the current item value so you can see each iteration in Launch Console
Continue loop (WA-2)On Continue, wires back to the loop for the next item; on Exit, moves to the done path
Send to Launch Console (WA-4)Logs Done after the loop finishes

The Loop ID bindings are already wired in the template:

  • Continue loop ID on the loop Wrk Action comes from Continue loop
  • Loop ID on Continue loop comes from Loop through JSON array
  • Notification content on the in-loop Send to Launch Console uses the current Item value

Swap [1, 2, 3] for your own array field from the Data Library, or point the loop at an array from an upstream API response.

Testing safely

Set Maximum number of items on Loop through JSON array while you debug. That caps how many elements the loop processes if your array is larger than expected.

Other loop patterns

This page starts with the simplest JSON array loop. For more patterns, see:

  • Looping — overview of loop types, pagination, and nested loops
  • Loop basics tutorial — video walkthrough with pagination and nested loop patterns