27 Jul 2026 05:11 PM
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:
// 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);
Solved! Go to Solution.
28 Jul 2026 12:29 AM
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 - Run JavaScript action for Workflows — Dynatrace Docs
2. predResult['result']
const result = predResult['result'];
exe.result() returns exactly what get_monitoring_config returned 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
Featured Posts