ForEach

The ForEach action executes a series of actions for each value in an array or object. In V1, the action works only for each value in an array.

The following table shows the parameters for the ForEach action.

Table 1. ForEach action parameters
Name Data type Description Required Notes
item JPath The path to store the current item of the iteration. Yes The path to store the current item of the iteration.
items JPath The array in the State to iterate. Yes The array in the State to iterate.
actions Actions[] The sequence of actions to execute for each iteration. Yes The sequence of actions to execute for each iteration. Cannot be empty.

XML Example

An array of objects exists in the State at /events. This action iterates through the array and executes the nested PostEvent action for each object in the array.

<ForEach item="/current_event" items="/events">
  <PostEvent path="/current_event" source="${/host}" />
</ForEach>