Add a For Each Action

You add a For Each action to execute actions for each item in an array.

To use a For Each action:

  1. Add the action in one of three ways, depending on your preference and where you want it added:
    • Drag the action from the Actions palette onto the canvas, dropping the action either at the bottom edge of the action it is to follow, or at the top edge of the action it is to precede.
    • Double-click the action in the Actions palette to add it to an empty canvas or to the end of an action chain.
    • On the canvas, select the action you want the new action to follow, then double-click the new action in the Actions palette.


  2. Configure the action's properties in the Properties pane:
    1. For Parameters, hover over the property's far-right side and click the down arrow that appears to choose the array to loop through, such as this array, $page.variables.ExpenseReportADP.data:

    2. For Mode, select whether your called actions run serially (default) or in parallel. Regardless of the mode, the For Each action will not complete until the actions for each item in the array are complete.
    3. For Item Alias, optionally, enter an alias for the current item in the array; the default is item.
    4. For Index Alias, optionally, enter an alias for the loop index, which starts at 0 and increases by 1 for each iteration. The default alias is index.
  3. Add the actions you want to take for each item of the array to the Add Action area of the For Each action. Here's an example that loops to call a REST endpoint (PATCH /ExpenseReport/{ExpenseReport_Id}) that updates the expense record at the current iteration:

On success, an array is returned with each element containing the return value from the last action in the loop, from each iteration. For instance, if the loop contains two actions that return results, actionA → actionB, and the loop iterates 5 times, the returned array will have 5 elements, each corresponding to an iteration and containing actionB's result from that iteration.

For API information about this action, see For Each in the Oracle Visual Builder Page Model Reference.