Add a For Each Action

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

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

To use a For Each action:

  1. Add the action in one of three ways, as explained at the end of Built-In Actions.
  2. Configure the action's properties in the Properties pane:
    1. For Parameters, hover over the property's far-right side and click Select Variable to choose the array to loop through, such as this array, $page.variables.expenseRecordsToUpdate.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:

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.