Created, retrieved and updated items can be handled in many ways, one of which is to use the For each node. This node will perform an action for each of the items that were created, retrieved or updated.

To use the For each node, click (+) and select it from the Toolbox tab in the flow editor. See the following section for an example about how to use the For each node.

Example of the For each node in the toolbox
For each node in the toolbox

Defining a For each node to retrieve high priority tickets

The following steps describe how to use the For each node with a retrieve action so that you can receive a notification for every service desk incident that has a high priority.

Using the For each node and JSONata to process high priority tickets flow tile
Using the For each node and JSONata to process high priority tickets flow tile

The following example uses the Atlassian Jira Service Desk application however you can use your preferred service desk application. Notifications in the following example will be displayed in the log however you may want to send notifications to Slack or use the Notification node.

Next, create your flow:

Using IBM App Connect Designer, you can create your flow from the template “Using the For each node and JSONata to process high priority tickets”, or by creating your flow from scratch.

Creating the flow from the template

This enables you to create the flow immediately, and then select each node in the flow to validate the node and select the application accounts that you want to use.

In App Connect Designer, complete the following steps:

  1. Select the Templates tab.
  2. On the Templates tab, click the tile “Using the For each node and JSONata to process high priority tickets”.
  3. Click “Create flow”.

Creating the flow from scratch

This helps you to learn the sequence of steps used to create the flow, and to examine the nodes and fields as you go.

(App Connect automatically saves your changes as you go. If you move away from the flow at any point, the flow is saved as a draft flow that you can come back to later.)

  1. Log in to App Connect Designer.
  2. From the Dashboard, click New > Event-driven flow.
  3. Enter a name that identifies the purpose of your flow.
  4. Select Toolbox > Scheduler.
  5. Update the following fields:
    • Select schedule type: Repeating interval
    • Run every: 1 Minute
    • Also run the flow when it’s first switched on: Select this box
  6. Click the (+) and then select Atlassian Jira Service Desk as your second application.
  7. If you haven’t already connected an Atlassian Jira Service Desk account, click Connect to Atlassian Jira Service Desk and follow the instructions to allow App Connect to connect to your Atlassian Jira Service Desk account.
  8. Select Issues > Retrieve issues.
  9. Specify the maximum number of issues that you want to retrieve, and what happens if the flow finds more than that number.
    1. We’ll set the limit to the maximum value allowed, to do this, click the Set the limit to the maximum value for Retrieve action icon.
    2. If the flow finds more issues than the maximum specified, we’ll process the maximum number of items that are found.
    3. If no items are found, then we’ll exit the flow with a ‘404’ error code.
  10. Defining the For each logic

  11. Now we’re ready to add the For each node. To do this, click (+) > Toolbox > For each.
  12. For the purposes of this example, we’ll be working with the fields inside the Input tab.
  13. In the *Select the collection of items to process:, we’re going to use some JSONata to process only the incidents that have a high priority.
  14. So, for each incident that has been marked as high priority we want to receive a notification in the log. To do this we need to use a JSONata filter higher order function. Begin by entering $filter. This will return an array containing only the values in the following array.
  15. To get the array, use the insert a reference icon to search for the Atlassian Jira incidents retrieve issues object.
  16. Add a comma after the object then enter function($v, $i, $a).
  17. Then we need to use the JSONata string function $contains(str, pattern). Which will return true if str is matched by pattern. In our case, if "High" is matched by So enter the following code {$contains($, "High")}).
  18. It should look like the following:
    For each node JSONata code example
    For each node JSONata code example
  19. Update the following fields as follows:
    • Display name: Atlassian JIRA Service Desk Issue (Priority=’High’ or ‘Highest’)
    • Collection processing options: Process all items in the collection sequentially
    • If an error occurs while processing an item: Process all other items and continue the flow
  20. Defining the log node

  21. After the For each node, click (+) > Toolbox > Log.
  22. Update the fields as follows:
    • *Log level: Info
    • *Message detail: Atlassian JIRA Issue {{$}} {{$}} This will log the Atlassian Jira ID along with the priority name in the log.
      Defining the Log node code example
      Defining the Log node
  23. The entire flow should look like the following image:
    An example of the complete flow displaying each node
    The complete flow
  24. From the banner, open the options menu [⋮] and click Start flow. Then click Dashboard to exit the flow. Your flow is displayed on your Dashboard and is listening for your event – the scheduler to run and retrieve issues.
    Example of the flow tile on the dashboard
    The flow tile on the Dashboard, showing that the flow is running and listening for events.

Finally, test your flow

  1. In the IBM Cloud App Connect UI, open the App Connect menu Icon for hamburger menu, and select Manage > Logs. The IBM Cloud Kibana Logging window opens in a new browser tab.
  2. You’ll see the logs with the message displayed exactly as we set them up – Atlassian JIRA Issue [Issue ID] [Priority name].
    Log results for the flow
    Log results for the flow

Other examples

Retrieving items from your applications

Join The Discussion

Your email address will not be published. Required fields are marked *