# Trying to access previous tasks output for javascript task

**URL:** <https://community.dynatrace.com/t/trying-to-access-previous-tasks-output-for-javascript-task/48590>\
**Category:** Automations\
**Tags:** dynatrace-sdk, workflows\
**Created:** [October 28, 2024, 4:12pm UTC](https://community.dynatrace.com/t/trying-to-access-previous-tasks-output-for-javascript-task/48590 "2024-10-28T16:12:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rseibert1](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@rseibert1](https://community.dynatrace.com/u/rseibert1)\
**Post date:** [October 28, 2024, 4:12pm UTC](https://community.dynatrace.com/t/trying-to-access-previous-tasks-output-for-javascript-task/48590/1 "2024-10-28T16:12:50Z")

</div>

My code is not returning anything to the log, I think I am following the proper format, must be something I am missing?

Note: Format taken from -&nbsp;[Run JavaScript action for Workflows — Dynatrace Docs](https://docs.dynatrace.com/docs/platform-modules/automations/workflows/default-workflow-actions/run-javascript-workflow-action)

Note: The previous task which completes successfully is - “get\_unhealthy\_workers”

import { execution } from ‘@dynatrace-sdk/automation-utils’;  
import { eventsClient } from “@dynatrace-sdk/client-classic-environment-v2”;

export default async function ({ execution\_id }) {  
var ex = await execution(execution\_id);  
var getunhealthyworkers = await ex.result(‘get\_unhealthy\_workers’);  
console.log('The whole result object: ', getunhealthyworkers.alertText);

}

The log from the execution:

The whole result object: undefined

---

<div class="post-metadata">

**Author:** ![ChristopherHejl](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/christopherhejl/32/20735_2.png) [@ChristopherHejl](https://community.dynatrace.com/u/ChristopherHejl)\
**Post date:** [October 29, 2024, 1:54pm UTC](https://community.dynatrace.com/t/trying-to-access-previous-tasks-output-for-javascript-task/48590/2 "2024-10-29T13:54:46Z")

</div>

The code looks ok, could you verify the task get\_unhealthy\_workers actually has a result?  
You can check that in an execution by looking at the result tab of the task details, example:

 ![ChristopherHejl_0-1730210081339.png](https://global.discourse-cdn.com/dynatrace/original/3X/a/b/abc14d9bfdd452d415880d222d467a5fa3c69b91.png)

---

<div class="post-metadata">

**Author:** ![rseibert1](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@rseibert1](https://community.dynatrace.com/u/rseibert1)\
**Post date:** [November 4, 2024, 10:38am UTC](https://community.dynatrace.com/t/trying-to-access-previous-tasks-output-for-javascript-task/48590/3 "2024-11-04T10:38:28Z")

</div>

Thanks, I had forgotten to make sure return worked, simple fix.
