Skip to main content
Kinetic Community

Evaluate if a Task Tree node executed

At times is it necessary to evaluated if a Task Tree node executed or not.  This is where using the Ruby method of has_key? can assist.

Usage

This need for has_key? is most common when the tree branches into multiple paths and one of the branches may not always execute.  Later in the tree the branches may join again.  Therefore, a bypassed node may not have executed at all.  A failure will occur if the results of a node, which didn't execute, are used in a connector or another node the node.has_key.png

When a Task Tree node may not be executed but the results of the node need to be evaluated, the existence of the node must first be evaluated using "has_key?".  To evaluate the results of a node named "Test Node 1", use "@results.has_key?('Test Node 1')".  If "Test Node 1" executed, the results of the previous statement will be true if otherwise it will be false.

Examples

Example for using in a connector (evaluates to true or false)

@results.has_key?('Test Node 1')

Example for use in a Task Tree Node

<%=

if @results.has_key?('Test Node 1')

    @results['Test Node 1']['output']

else

    "Test Node 1 did not execute"

end

%>

Downloadable Example

Download and install this example onto a Kinetic Request Server to see a working examle.  Then submit a request and examine the results in the "Executions" tab of "Kinetic Task Management Console".

haskey_example.zip