Now inviting automation leaders: publish your playbook as a skill, under your own name. Publish yours →
Automation Skills
All skills/Uipath maestro flow/Loops
Reference · Uipath maestro flow

Loops

Part of Uipath maestro flow. Install the skill and your agent reads this page when it needs the depth.

Loops

Run a body once per collection member: .loop(name, collection, bodyFn, options?). Keep per-item dispatch and decisions in the body. Write values needed after the loop to a .var() via a body step's { updates }; parallel results differ (parallel: true in Loop options).

Loops are sequential by default (parallel: false). In the body, read $vars.<loop>.currentItem and $vars.<loop>.currentIteration, or v('<loop>.currentItem') from the builder. The item is named after the LOOP, never the collection: there is no $vars.item, $vars.currentItem, or $vars.<collection>; a branch or step deciding on the item names the loop, so loop eachIssue reads $vars.eachIssue.currentItem.priority, never $vars.item.priority, which resolves to nothing and takes the false arm on every iteration without erroring. A one-armed branch (rest of the iteration in its yes arm) skips the rest of one iteration without terminating the run: when its condition is false, that iteration completes and the loop advances. A non-2xx HTTP result fails its step and faults the loop; end an .onError() handler on that step with .continue() to skip that item (Loop options).

currentIndex is legacy loop 1.0.0 only. On default 2.4 it is undefined; check rejects it with UNKNOWN_LOOP_FIELD and suggests currentIteration - 1 for a 0-based index. Do not rely on currentIteration's exact base: 2.4 documents 1-based, but local flow-debug currently reads 0 for the first item and the cloud runtime is unverified (flow-builder-sdk#874). If the result depends on the number, confirm it with a live uip maestro flow debug run (ask first).

At a glance

Every .loop() emits core.logic.loop 2.4. Body writes use { updates }, never a mutation node. Read $vars.<loop>.currentItem and $vars.<loop>.currentIteration, not legacy currentIndex. Options are parallel: true, completionCondition (checked after each iteration), body.break() (exits the loop), and body.continue() (advances to the next item).

Loop options

.loop() emits the 2.4 definition with inner start/continue/break handles, matching the registry and designer. Emit legacy 1.0.0 only with { version: '1.0.0' }; it uses body from output, a back-edge into loopBack, and currentIndex. On 1.0.0, body.continue() works; breakEnabled and body.break() fail check with LOOP_VERSION_UNSUPPORTED. completionCondition passes check on 1.0.0 with @uipath/maestro-builder-sdk 6.86.25 or later; older SDKs fail check with LOOP_VERSION_UNSUPPORTED. parallel: true on 1.0.0 compiles only to round-trip a canvas 1.0.0 loop and check warns LOOP_PARALLEL_LEGACY; 1.0.0 is not confirmed to run iterations in parallel. For a new parallel loop, omit version (2.4).

.loop('each', input('items'), (body) => body
  .step('call', http({ url: 'https://api.example.test/items', method: 'POST', managed: true }))
  .onError((h) => h
    .step('logFailure', script({ code: 'return "logged";' }))
    .continue()))
.var('found', types.string, '')
.loop('scan', input('items'), (body) => body
  .step('probe', script({ code: 'return $vars.scan.currentItem;', returns: 'object' }),
    { updates: { found: js`$vars.probe.output.id` } })
  .branch('hit', js`$vars.probe.output.score > 90`, (t) => t.break()),
  { completionCondition: js`$vars.found !== ""` })

Do while

.doWhile(name, condition, bodyFn, { limit?, breakEnabled? }) runs the body, then repeats while the condition is true; the condition is checked AFTER each pass, so the body always runs at least once (core.logic.dowhile). The container publishes no data output: write results to a .var() inside the body with { updates }. limit caps iterations at 1–10,000; blank means the platform default of 10,000. body.break() and body.continue() work exactly as in .loop(). A body-step failure can route to .onError() after .doWhile(...), as with .loop() (error-handling.md).

.var('page', types.number, 1)
.doWhile('paginate', js`$vars.fetch.output.body.hasNextPage === true`, (body) => body
  .step('fetch', http({ url: tmpl`https://api.example.test/items?page=${v('page')}`,
    method: 'GET', managed: true, returns: { hasNextPage: 'boolean' } }),
    { updates: { page: js`$vars.page + 1` } }),
  { limit: 50 })

Publish your skill

Copy this prompt into Claude Code, Codex or any agent. It walks you through your first skill in about 20 minutes, with you as the author.

Click to copy.