# How do I use the result from a previous JavaScript task into a new JavaScript task?

**URL:** <https://community.dynatrace.com/t/how-do-i-use-the-result-from-a-previous-javascript-task-into-a-new-javascript-task/56568>\
**Category:** Automations\
**Tags:** workflows, automations\
**Created:** [July 27, 2026, 4:11pm UTC](https://community.dynatrace.com/t/how-do-i-use-the-result-from-a-previous-javascript-task-into-a-new-javascript-task/56568 "2026-07-27T16:11:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![badgerfifteen](https://avatars.discourse-cdn.com/v4/letter/b/e68b1a/32.png) [@badgerfifteen](https://community.dynatrace.com/u/badgerfifteen)\
**Post date:** [July 27, 2026, 4:11pm UTC](https://community.dynatrace.com/t/how-do-i-use-the-result-from-a-previous-javascript-task-into-a-new-javascript-task/56568/1 "2026-07-27T16:11:29Z")

</div>

I have a previous JavaScript task named **get\_monitoring\_config** which returns a JSON. However, it is returning as ‘undefined’ in the console so I can’t use it.

Here is a better snippet of my code:

```markup
// 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);

```

---

<div class="post-metadata">

**Author:** ![sujit\_k\_singh](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@sujit\_k\_singh](https://community.dynatrace.com/u/sujit_k_singh)\
**Post date:** [July 27, 2026, 11:29pm UTC](https://community.dynatrace.com/t/how-do-i-use-the-result-from-a-previous-javascript-task-into-a-new-javascript-task/56568/2 "2026-07-27T23:29:12Z")

</div>

Hi&nbsp;[@badgerfifteen](https://community.dynatrace.com/user/67521)

I think there are two issues in your code.

1. Function signature

Your snippet has:

**export default async function (executionId, actionExecutionId) {…**

Dynatrace expects a single destructured object parameter, not two positional args:

**export default async function ({ executionId, actionExecutionId })** {

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.

see the document -&nbsp;[Run JavaScript action for Workflows — Dynatrace Docs](https://docs.dynatrace.com/docs/analyze-explore-automate/workflows/default-workflow-actions/run-javascript-workflow-action)

 ![sujit_k_singh_0-1785194619318.png](https://global.discourse-cdn.com/dynatrace/original/3X/c/6/c6b5a07c670d0f1f6b83fe695e9a90f4c509b6cf.png)

2. predResult[‘result’]

**const result = predResult[‘result’];**

**exe.result()** returns exactly what **get\_monitoring\_config r** 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.

You’re also shadowing the result you **imported from @dynatrace-sdk/automation-utils** by naming a local variable **result** — worth renaming to avoid confusion later.

Thanks,

Sujit
