Skip to main content

IMPORTANT - Product End of Life Statement - IMPORTANT

Request RE, Survey, and Calendar 1.5 Support Ending December 31, 2020
Contact Kinetic Data Support with Questions
Kinetic Community

Using Loops in the Task Builder

How to use the Loop task handlers in the Task Builder


Loops are a great way to implement repeated tasks. Some examples include, multiple approvers per level and creating groups of remedy tickets, like tasks.

There are two handlers that are a part of any loop, the Loop Begin and Loop End. The handlers are listed as Loop Head and Loop Tail in the System Controls in the Tree builder. Loop Begin and Loop Head are equivalent terms and so are Loop End and Loop Tail.

Loop Begin

This handler collects the information on how many times the loop should process, and any variable provided in the loop that can be used by other handlers.

See screenshots below.

Parameters from the Loop Begin handler:

Data Source: This parameter holds an xml string that defines how many times the loop processes. Here is an example string:

  <myID>Han Solo</myID>
The outer node (userID) is required to encapsulate the inner node (myID) that defines how many times the loop processes. In this case, it will process two times.
Most real world implementations do not use hard coded values like above. In those cases you will have the result goto another node to use in the Data Source field. Task Handlers that can turn either csv or json strings into xml are valuable when using loops. You can find a few in the Utility category of Kinetic Task.
Loop Path: Used to define the path in the xml document to the data. Example path for the above xml:
Unlike Data Source this is often a hard coded value. Once the format of the XML is set (normally an output of a previous handler), the path will not change.
Variable Name: a name that is used by nodes within the loop to reference the data from the xml. The most common use is for the data represented by the variable to be used in a lookup of some kind. The only restriction on the variable name is that it cannot be the same as either of the node names from the xml string. In the above example we are using myUserID. userID or myID are invalid variable names.  To reference this variable in the other nodes in the loop you add an @ sign, and wrap it in the wrap it "<%" tags, so myUserID would be referenced as <%= @myUserID %>.
Another option that is becoming more popular is to use the output of the Loop Begin node, it has the same value as the Variable Name, but fits in the format used by results and other nodes in the builder. The format is <%=@results['Loop Begin']['Value']%> and is available along with the other Task Results from the Parameter menu in the nodes.

Loop End

This handler determines what the conditions are for progressing beyond the loop. 
Parameters from the Loop End handler:
Type: Set the criteria for complete connectors coming into the loop end node. Options are Any, All, Some - if you select Some you must specify a number. Each separate run through the loop creates a connector to the loop end. In the example xml above the loop would process 2 times, so there will be two connectors processed against the Loop End.
This handler is similar to a Join handler.

Connecting the Loop Handlers

To connect the Begin and End Loop handlers, you draw a Complete Connector starting from the Loop Begin handler and terminating at the Loop End Handler.


Here is a screen shot of a simple Loop:

loop_example_basic Tree.png

Another example with details of the Loop Begin:


Example with details of an ITSM Approver Lookup by Role: