Using the For each node
You can handle created, retrieved, and updated items in many ways. One way is to use the For each node. This node completes an action for each of the items that were created, retrieved, or updated.
In App Connect, to add a For each node to your flow, click (+) and then select it from the Toolbox tab in the flow editor.
The following example shows how to use the For each node with a retrieve action. In this example, you can receive a notification for every Jira incident that has a high priority.
Find or create what you need
Create your flow
Use App Connect to create your flow from a template, or from scratch if you want to explore the steps that are taken to create a flow.
Creating the flow from scratch
You can create a flow from scratch to learn the sequence of steps that are used to create the flow, and to examine the nodes and fields as you go.
- Log in to App Connect.
- From the Dashboard, click .
- Enter a name that identifies the purpose of your flow.
- Select .
- Update the following fields:
- Set Select schedule type to Repeating interval.
- Set Run every to 1 Minute.
- Select Also run the flow when it's first switched on.
- Click the (+) and then select Jira as your second application.
- Select .
- If App Connect tisn't connected o your Jira account, click Connect, then follow the instructions to allow App Connect to connect to your Jira account.
- Specify the maximum number of issues that you want to retrieve, and what happens if the flow
finds more than that number.
- To set the limit to the maximum allowed value, click Set the limit to the maximum value .
- If the flow finds more issues than the specified maximum, the maximum number of items that are found are processed.
- If no items are found, the flow stops with a
404
error code.
- To define the logic for each record to process, add the For each node by clicking Add node (+), then . For the purposes of this example, you use the fields on the Input tab.
- For each incident that has been marked as high priority, you want to receive a notification in
the log. You can filter incidents by using a JSONata filter higher order function to process only
the incidents that have a high priority. In Select the collection of items to
process, enter $filter, then select the
$filter()
function. This filter returns an array that contains only the values in the following array. - In the array segment, click Insert a mapping , then expand Jira and Retrieve all issues, and select IssueCollection.
- In the function segment, enter function($v, $i, $a).
- You now need to use the JSONata string function
$contains(str, pattern)
to returntrue
ifstr
is matched bypattern
. In this example,High
needs to matchfields.priority.name
. Enter the following code {$contains($v.fields.priority.name, "High")}).The complete JSONata code is as follows:$filter($JiraRetrieveallissues,function($v, $i, $a){$contains($v.fields.priority.name, "High")})
- Update the following fields.
- Set the Display name to Atlassian JIRA Service Desk Issue (Priority="High" or "Highest").
- Set Collection processing options to Process all items in the collection sequentially.
- Set If an error occurs while processing an item to Process all other items and continue the flow.
- After the For each node, add a Log node by clicking Add node (+), then .
- Update the following fields.
- Set the Log level to Info.
- Set the Message detail to Atlassian JIRA Issue
{{$Foreachitem.id}} {{$Foreachitem.fields.priority.name}}.
This property logs the Atlassian Jira ID with the priority name in the log.
The following example shows the complete flow.
- To test the flow, click Start flow, then click
Dashboard to exit the flow.
Your flow is displayed on the Designer dashboard and is listening for your event, which is the Scheduler to run and retrieve issues.
Test your flow
After a moment, a green tick is shown on the tile to indicate that the flow has run successfully. You can now check the log for entries added for each Jira issue that has a high priority.
- Open the Logs view .
You can see the message in the logs as you configured it (
Atlassian JIRA Issue [Issue ID] [Priority name]
).