Break

Use the Break task inside a ForEach loop to stop the execution.

When the Break task runs:

  • The rest of the current iteration is skipped.
  • No further iterations run.
  • The job continues with the first task after the ForEach End of the loop.

Example

The following job exports data for each region but stops the loop when more than 10 errors have accumulated:

Open Analysis from Library
ForEach (Data Table: "Regions", Column: "Region")
    If
        result = AutomationContext.Application.Document.Properties["ErrorCount"] > 10
        Break
    End If
    Export Data
ForEach End