<?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 do I use the result from a previous JavaScript task into a new JavaScript task? in Automations</title>
    <link>https://community.dynatrace.com/t5/Automations/How-do-I-use-the-result-from-a-previous-JavaScript-task-into-a/m-p/302456#M2706</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/67521"&gt;@badgerfifteen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think there are two issues in your code.&lt;/P&gt;&lt;P&gt;1. Function signature&lt;/P&gt;&lt;P&gt;Your snippet has:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;export default async function (executionId, actionExecutionId) {.....&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Dynatrace expects a single destructured object parameter, not two positional args:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;export default async function ({ executionId, actionExecutionId })&lt;/STRONG&gt; {&lt;/P&gt;&lt;P&gt;Without the braces, the runtime still only passes one argument into your function — so executionId ends up being the entire context object, and actionExecutionId is undefined. This can throw off execution(executionId) downstream since it's not getting the plain ID string it expects.&lt;/P&gt;&lt;P&gt;see the document -&amp;nbsp;&lt;A href="https://docs.dynatrace.com/docs/analyze-explore-automate/workflows/default-workflow-actions/run-javascript-workflow-action" target="_blank"&gt;Run JavaScript action for Workflows — Dynatrace Docs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sujit_k_singh_0-1785194619318.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/33773i47408C28C5184533/image-size/large?v=v2&amp;amp;px=999" role="button" title="sujit_k_singh_0-1785194619318.png" alt="sujit_k_singh_0-1785194619318.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. predResult['result']&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;const result = predResult['result'];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;exe.result()&lt;/STRONG&gt; returns exactly what &lt;STRONG&gt;get_monitoring_config r&lt;/STRONG&gt;eturned it's not automatically wrapped in a result key. Unless that task explicitly does return { result: ... }, predResult already is your JSON payload, and predResult['result'] will be undefined. That matches the symptom you're seeing.&lt;/P&gt;&lt;P&gt;You're also shadowing the result you &lt;STRONG&gt;imported from @dynatrace-sdk/automation-utils&lt;/STRONG&gt; by naming a local variable &lt;STRONG&gt;result&lt;/STRONG&gt; — worth renaming to avoid confusion later.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sujit&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jul 2026 23:29:12 GMT</pubDate>
    <dc:creator>sujit_k_singh</dc:creator>
    <dc:date>2026-07-27T23:29:12Z</dc:date>
    <item>
      <title>How do I use the result from a previous JavaScript task into a new JavaScript task?</title>
      <link>https://community.dynatrace.com/t5/Automations/How-do-I-use-the-result-from-a-previous-JavaScript-task-into-a/m-p/302434#M2705</link>
      <description>&lt;P&gt;I have a previous JavaScript task named &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;get_monitoring_config &lt;/FONT&gt;&lt;/STRONG&gt;which returns a JSON. However, it is returning as 'undefined' in the console so I can't use it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a better snippet of my code:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// optional import of sdk modules
import { execution, result } from '@dynatrace-sdk/automation-utils';
import { extensions_2_0Client } from "@dynatrace-sdk/client-classic-environment-v2";

 
export default async function (executionId, actionExecutionId) {

const exe = await execution();
const TASK_ID = 'get_monitoring_config'; 
const predResult = await exe.result(TASK_ID); 
const result = predResult['result']; 
console.log(result);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2026 16:11:29 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/How-do-I-use-the-result-from-a-previous-JavaScript-task-into-a/m-p/302434#M2705</guid>
      <dc:creator>badgerfifteen</dc:creator>
      <dc:date>2026-07-27T16:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use the result from a previous JavaScript task into a new JavaScript task?</title>
      <link>https://community.dynatrace.com/t5/Automations/How-do-I-use-the-result-from-a-previous-JavaScript-task-into-a/m-p/302456#M2706</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/67521"&gt;@badgerfifteen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think there are two issues in your code.&lt;/P&gt;&lt;P&gt;1. Function signature&lt;/P&gt;&lt;P&gt;Your snippet has:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;export default async function (executionId, actionExecutionId) {.....&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Dynatrace expects a single destructured object parameter, not two positional args:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;export default async function ({ executionId, actionExecutionId })&lt;/STRONG&gt; {&lt;/P&gt;&lt;P&gt;Without the braces, the runtime still only passes one argument into your function — so executionId ends up being the entire context object, and actionExecutionId is undefined. This can throw off execution(executionId) downstream since it's not getting the plain ID string it expects.&lt;/P&gt;&lt;P&gt;see the document -&amp;nbsp;&lt;A href="https://docs.dynatrace.com/docs/analyze-explore-automate/workflows/default-workflow-actions/run-javascript-workflow-action" target="_blank"&gt;Run JavaScript action for Workflows — Dynatrace Docs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sujit_k_singh_0-1785194619318.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/33773i47408C28C5184533/image-size/large?v=v2&amp;amp;px=999" role="button" title="sujit_k_singh_0-1785194619318.png" alt="sujit_k_singh_0-1785194619318.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. predResult['result']&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;const result = predResult['result'];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;exe.result()&lt;/STRONG&gt; returns exactly what &lt;STRONG&gt;get_monitoring_config r&lt;/STRONG&gt;eturned it's not automatically wrapped in a result key. Unless that task explicitly does return { result: ... }, predResult already is your JSON payload, and predResult['result'] will be undefined. That matches the symptom you're seeing.&lt;/P&gt;&lt;P&gt;You're also shadowing the result you &lt;STRONG&gt;imported from @dynatrace-sdk/automation-utils&lt;/STRONG&gt; by naming a local variable &lt;STRONG&gt;result&lt;/STRONG&gt; — worth renaming to avoid confusion later.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sujit&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2026 23:29:12 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/How-do-I-use-the-result-from-a-previous-JavaScript-task-into-a/m-p/302456#M2706</guid>
      <dc:creator>sujit_k_singh</dc:creator>
      <dc:date>2026-07-27T23:29:12Z</dc:date>
    </item>
  </channel>
</rss>

