Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to access var from preceding javascript task in condition logic of current task



I have the following -


run_javascript_1 - javascript action containing logic that determines the variable's value 'booleanVariable'.

send_message_1 - send message to teams channel action. Want only to execute this task if 'booleanVariable' from preceding action == true.

This page outlines the basic use of expressions. And according to said page, 'result('nameoftask')' gives access to the result object and anything within, however I can't find any documentation on how to include the variable and its value in the result object of the preceding action. There's also a task('nameoftask'), but the same issue exists - how do I include the variable and its value in the 'task' object?


The following condition logic, which I've tried, doesn'twork:

- {{result("run_javascript_1").booleanVariableis true}}

- {{result("run_javascript_1").booleanVariable== true}} <- error:  Undefined variables in '{{result("run_javascript_1").booleanVariable== false }}': booleanVariable

- {{task("run_javascript_1").booleanVariableis true}}

- {{task("run_javascript_1").booleanVariable== true}} <- error:  Undefined variables in '{{task("run_javascript_1").booleanVariable== false }}': booleanVariable




I have decided to do a workaround.

Instead of the condition logic checking if booleanVariable is true and the action only executing in that case, I throw an error in the javascript action if the booleanVariable is false and then the following action that would've had the condition logic simply only executes if the preceding javascript action succeeds.

However, the same problem still exists. I need to be able to access the value of a variable from the javascript action, in a following action. It is not clear if this is possible. I think the only way is to add it as an attribute  to either the task or result object, but it there is no documentation outlining this process.

Dynatrace Helper
Dynatrace Helper


in order to make data available as the result of a javascript task, you can return the object.

export default async function ({ execution_id }) {
  // your code goes here

  return { 
    my_string: "Some text",
    my_number: 42,
    booleanVariable: false




In case of checking a booelan variable, the condition check can be as simple as this

{{ result("custom_javascript_sample")["booleanVariable"] }}



or a combination 

{{ result("custom_javascript_sample")["booleanVariable"] or result("custom_javascript_sample")["my_number"] > 12}}



Featured Posts