<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to access var from preceding javascript task in condition logic of current task in Automations</title>
    <link>https://community.dynatrace.com/t5/Automations/How-to-access-var-from-preceding-javascript-task-in-condition/m-p/250207#M1683</link>
    <description>&lt;P&gt;I have decided to do a workaround.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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&amp;nbsp; to either the task or result object, but it there is no documentation outlining this process.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jul 2024 01:38:17 GMT</pubDate>
    <dc:creator>tabhne</dc:creator>
    <dc:date>2024-07-10T01:38:17Z</dc:date>
    <item>
      <title>How to access var from preceding javascript task in condition logic of current task</title>
      <link>https://community.dynatrace.com/t5/Automations/How-to-access-var-from-preceding-javascript-task-in-condition/m-p/250206#M1682</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have the following -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run_javascript_1 - javascript action containing logic that determines the variable's value 'booleanVariable'.&lt;/P&gt;
&lt;P&gt;send_message_1 - send message to teams channel action. Want only to execute this task if 'booleanVariable' from preceding action == true.&lt;BR /&gt;&lt;BR /&gt;This page&amp;nbsp;&lt;A href="https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference" target="_blank" rel="noopener"&gt;https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference&lt;/A&gt;&amp;nbsp;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?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following condition logic, which I've tried, doesn'twork:&lt;/P&gt;
&lt;P&gt;- {{result("run_javascript_1").booleanVariableis true}}&lt;/P&gt;
&lt;P&gt;- {{result("run_javascript_1").booleanVariable== true}} &amp;lt;- error: &lt;SPAN&gt;&amp;nbsp;Undefined variables in '{{result("run_javascript_1").booleanVariable== false }}': booleanVariable&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;- {{task("run_javascript_1").booleanVariableis true}}&lt;/P&gt;
&lt;P&gt;- {{task("run_javascript_1").booleanVariable== true}} &amp;lt;- error: &lt;SPAN&gt;&amp;nbsp;Undefined variables in '{{task("run_javascript_1").booleanVariable== false }}': booleanVariable&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2024 12:54:53 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/How-to-access-var-from-preceding-javascript-task-in-condition/m-p/250206#M1682</guid>
      <dc:creator>tabhne</dc:creator>
      <dc:date>2024-07-12T12:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to access var from preceding javascript task in condition logic of current task</title>
      <link>https://community.dynatrace.com/t5/Automations/How-to-access-var-from-preceding-javascript-task-in-condition/m-p/250207#M1683</link>
      <description>&lt;P&gt;I have decided to do a workaround.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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&amp;nbsp; to either the task or result object, but it there is no documentation outlining this process.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 01:38:17 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/How-to-access-var-from-preceding-javascript-task-in-condition/m-p/250207#M1683</guid>
      <dc:creator>tabhne</dc:creator>
      <dc:date>2024-07-10T01:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to access var from preceding javascript task in condition logic of current task</title>
      <link>https://community.dynatrace.com/t5/Automations/How-to-access-var-from-preceding-javascript-task-in-condition/m-p/250511#M1698</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;in order to make data available as the result of a javascript task, you can return the object.&lt;BR /&gt;Example:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;export default async function ({ execution_id }) {
  // your code goes here

  return { 
    my_string: "Some text",
    my_number: 42,
    booleanVariable: false
  };
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChristopherHejl_2-1720792494137.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/21121iD0A18AAEE7FEF8B6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChristopherHejl_2-1720792494137.png" alt="ChristopherHejl_2-1720792494137.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In case of checking a booelan variable, the condition check can be as simple as this&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;{{ result("custom_javascript_sample")["booleanVariable"] }}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChristopherHejl_1-1720792483459.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/21120i19BB6454DAE3C8B9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChristopherHejl_1-1720792483459.png" alt="ChristopherHejl_1-1720792483459.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;or a combination&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;{{ result("custom_javascript_sample")["booleanVariable"] or result("custom_javascript_sample")["my_number"] &amp;gt; 12}}&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChristopherHejl_3-1720792614504.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/21122i11A4BFE87D396FB5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChristopherHejl_3-1720792614504.png" alt="ChristopherHejl_3-1720792614504.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2024 13:57:05 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/How-to-access-var-from-preceding-javascript-task-in-condition/m-p/250511#M1698</guid>
      <dc:creator>ChristopherHejl</dc:creator>
      <dc:date>2024-07-12T13:57:05Z</dc:date>
    </item>
  </channel>
</rss>

