Skip to main content
Version: 1.28 (Current)

Repeat

Audience: Low-code Engineers

Skill Prerequisites: Actions, Tokens, Conditions

Runs a list of actions several times. The loop can run:

  • a fixed number of times, like a for loop, using Repetitions
  • while a condition is true, like a while loop, using While Condition
  • both: while the condition is true, but never more than Repetitions times

The current repetition number is available in the [<BaseNameToken>:CurrentLoopNumber] token, starting at 1.

Typical Use Cases​

  • Process data in batches, for example call a stored procedure once for each of 10 batches
  • Poll an external service until a job finishes, with a maximum number of attempts
  • Retry a call that sometimes fails
  • Build up a value over several steps, for example a running total

Don't use it to​

Action NameDescription
Execute Actions for each List EntryRuns actions once for each entry in a list.
Execute ActionsRuns a list of actions once, with error handling.
WaitPauses between repetitions, for example when polling or respecting rate limits.
Stop ExecutionEnds the loop and all remaining actions.

Input Parameter Reference​

ParameterDescriptionSupports TokensDefaultRequired
Base Name TokenA name for the loop, for example Batch. It's used to build the [Batch:CurrentLoopNumber] token. Nested loops need different names.Yesempty stringYes
RepetitionsThe maximum number of times to run the actions. Must be a whole number greater than zero, for example 10 or [BatchCount]. Leave empty to repeat for as long as While Condition is true.Yesempty stringNo
While ConditionA condition checked before each repetition. The loop stops as soon as it's false. For example [Job:Status] != "Done". Leave empty to rely on Repetitions only.Yesempty stringNo
ActionsThe actions to run in each repetition.NoemptyYes
Context BehaviorWhat happens to tokens created or changed during each repetition. See Context behavior.NoUpdate all tokens in the original contextNo
Continue on errorWhen checked, a failed repetition is written to the site's event log and the loop moves on to the next repetition. When unchecked, a failed repetition ends the loop.NoUncheckedNo
On ErrorActions to run when a repetition fails. See How errors are handled.NoemptyNo

If both Repetitions and While Condition are empty, the action does nothing.

Context behavior​

Each repetition runs on a copy of the tokens. Context Behavior decides what's copied back after each repetition. This matters because the next repetition, the While Condition and the actions after the loop all read from the original tokens.

OptionWhat's copied back after each repetitionUse it when
Update all tokens in the original context (default)Every token created or changed in the repetition.The next repetition, the While Condition or the actions after the loop need values from the loop.
Don't save the iteration tokensNothing. Every repetition starts from the tokens as they were before the loop.Each repetition is independent and you don't need its results afterwards.
Update the tokens in the initial contextOnly tokens that already existed before the loop. New tokens are discarded.You want to carry specific values, such as a running total, without leaking other tokens. Create those tokens with an initial value before the loop.
caution

The While Condition reads the original tokens. With Don't save the iteration tokens, a condition based on a token that's changed inside the loop never changes, so the loop could run forever. Always set Repetitions as a safety limit when you use While Condition.

How errors are handled​

Continue on errorOn ErrorWhat happens when a repetition fails
UncheckedemptyThe loop ends and the error is passed up.
Uncheckedhas actionsThe On Error actions run. If one of them ends execution, for example Display Message, execution ends there. Otherwise the error is passed up.
CheckedanyThe On Error actions run, the error is written to the site's event log, and the loop continues with the next repetition. Messages, redirects and other results from On Error are ignored.

Unlike Execute Actions, the On Error actions of Repeat don't receive the [Exception], [ExceptionMessage] and related tokens. To capture error details, put an Execute Actions with its own On Error inside the loop.

Considerations​

  • Actions that end execution end the loop and all remaining actions. If an action inside the loop shows a message, redirects or is Stop Execution, no further repetitions run and the actions after Repeat don't run either.
  • Unique names. The action fails with A loop with the name ... already exists if Base Name Token is already in use by an enclosing loop. Loops that run one after the other can reuse a name.
  • After the loop. The [<BaseNameToken>:CurrentLoopNumber] token is removed when the loop ends.
  • Numbers in conditions. Token values are compared as numbers when the other side is a number, so [Batch:CurrentLoopNumber] <= 5 works.
  • Long loops hold up the request. In forms and grids, keep the number of repetitions small, or run the loop in Execute Actions Asynchronously.

Examples​

tip

To understand how to use the below examples, please see Running Examples.

1. Process ten batches​

This action calls a stored procedure ten times, passing the batch number 1 to 10.

{
"Title": "Repeat",
"ActionType": "LoopActions",
"Description": "Process batches 1 to 10",
"Condition": null,
"Parameters": {
"BaseNameToken": "Batch",
"Repetitions": "10",
"EndCondition": "",
"ActionList": [
{
"Title": "Run SQL Query",
"ActionType": "RunSql",
"Parameters": {
"ConnectionString": "",
"QueryTimeout": "",
"SqlQuery": "EXEC dbo.ProcessBatch [Batch:CurrentLoopNumber]",
"BindTokens": "",
"OutputTokenName": "",
"ExtractColumns": "",
"OnError": [],
"ShowErrors": false
}
}
],
"ContextBehavior": {
"Expression": "",
"Value": "NoPreserve",
"IsExpression": false,
"Parameters": {}
},
"ContinueOnError": false,
"OnError": []
}
}

2. Poll a job until it finishes​

This action checks a job's status every two seconds until it's Done, for at most 15 attempts. The query saves the status in [Job:Status], and Update all tokens in the original context copies it back so the While Condition sees the new value. Before the first check, [Job:Status] is empty, so the condition is true.

{
"Title": "Repeat",
"ActionType": "LoopActions",
"Description": "Wait for the export job to finish",
"Condition": null,
"Parameters": {
"BaseNameToken": "Poll",
"Repetitions": "15",
"EndCondition": "[Job:Status] != \"Done\"",
"ActionList": [
{
"Title": "Run SQL Query",
"ActionType": "RunSql",
"Parameters": {
"ConnectionString": "",
"QueryTimeout": "",
"SqlQuery": "SELECT Status FROM ExportJobs WHERE JobId = [ExportJobId]",
"BindTokens": "",
"OutputTokenName": "Job",
"ExtractColumns": "",
"OnError": [],
"ShowErrors": false
}
},
{
"Title": "Wait",
"ActionType": "Wait",
"Parameters": {
"TimeMs": "2000"
}
}
],
"ContextBehavior": {
"Expression": "",
"Value": "UpdateAllTokens",
"IsExpression": false,
"Parameters": {}
},
"ContinueOnError": false,
"OnError": []
}
}

In this example [ExportJobId] comes from an earlier action, not from user input. Use Bind Tokens in Run SQL Query for values that users can change.

Revised 09/25/2026