13 Mar 2025 03:19 PM
Hi folks,
I need help in writing some JS code for a workflow.
In a previous step i have a HTTP API request the pulls data and returns the payload in JSON. the step name is "sn_step1"
// import of sdk modules
import { execution } from '@dynatrace-sdk/automation-utils';
export default async function ({ execution_id }) {
const exe = await execution(execution_id);
const checkResult = await exe.result('sn_step1');
const Scope = data[0].json.scope;
return Scope;
console.log(Scope);
im just trying to log the output in this step to see if i can pull in the json output from previous step
Solved! Go to Solution.
13 Mar 2025 03:50 PM
Almost there. You now have the result data in "checkResult". Here is my example code based on your data. I've also attached the whole example workflow which you can upload in the workflows app (upload button next to create workflow, just upload the json file in the zip):
import { execution } from '@dynatrace-sdk/automation-utils';
export default async function ({ executionId }) {
const exe = await execution(executionId);
const checkResult = await exe.result('sn_step1');
console.log("This is the full result object")
console.log(checkResult)
console.log("===============================")
const firstItem = checkResult[0]
console.log("This is the first item of the list")
console.log(firstItem)
console.log("===============================")
console.log("This is the number of the first item of the list")
console.log(firstItem.number)
console.log("===============================")
}
13 Mar 2025 04:07 PM
Thanks this is what I was looking for