Skip to main content

For@1

Node For@1 allows to iterate from 0 to a specified number of iterations and execute a sub transformation pipeline for each iteration.

The node produces an array of outputs, one for each iteration.

Adapter Prerequisites

  • General availability: All adapters support this node type.

Node Configuration

For fields path, targetPath, targetValueWriteMode, and targetValueKind, see Overview.

PropertyTypeRequiredDescription
countintegernoStatic number of iterations. Used when countPath is not set.
countPathstringnoJSON path to dynamically resolve the iteration count from the data context. Takes precedence over count when set.
indexTargetPathstringnoPath where the current iteration index (0-based) is stored.
maxDegreeOfParallelismintegernoMaximum degree of parallelism. 0 = processor count (default), -1 = unlimited, positive = explicit limit.
transformationsarrayyesSub pipeline nodes executed for each iteration.
note

Either count or countPath should be provided. When both are set, countPath takes precedence.

Static Count Example

transformations:
- type: For@1
count: 4 # Number of iterations
targetPath: customers # Path where the data should be stored in the payload (will be an array)
transformations: # Sub pipeline that will be executed for each iteration
- type: Simulation@1
simulations:
- targetPath: $.customer.firstName
simulatorKey: Person.FirstName
- targetPath: $.customer.lastName
simulatorKey: Person.LastName
- targetPath: $.customer.street
simulatorKey: Address.StreetName

Dynamic Count Example

When the iteration count needs to come from the data context (e.g., from an HTTP request body), use countPath:

transformations:
- type: FromHttpRequest@1
method: POST
path: /create-items
- type: For@1
countPath: $.count # Reads count from the HTTP request body
indexTargetPath: $.index
targetPath: $.results
transformations:
- type: FormatString@1
format: "Item-{$.index}"
targetPath: $.name