# Access event data or results from a previous workflow step

**URL:** <https://community.dynatrace.com/t/access-event-data-or-results-from-a-previous-workflow-step/39863>\
**Category:** Automations\
**Tags:** automationengine, latest-dynatrace, workflows, automation\
**Created:** [May 23, 2023, 9:27am UTC](https://community.dynatrace.com/t/access-event-data-or-results-from-a-previous-workflow-step/39863 "2023-05-23T09:27:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![agata.wlodarczyk](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/agata.wlodarczyk/32/22_2.png) [@agata.wlodarczyk](https://community.dynatrace.com/u/agata.wlodarczyk)\
**Post date:** [May 23, 2023, 9:27am UTC](https://community.dynatrace.com/t/access-event-data-or-results-from-a-previous-workflow-step/39863/1 "2023-05-23T09:27:40Z")

</div>

How do I access event data or results from a previous workflow step?

---

<div class="post-metadata">

**Author:** ![michaelwinkler](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/michaelwinkler/32/29293_2.png) [@michaelwinkler](https://community.dynatrace.com/u/michaelwinkler)\
**Post date:** [May 23, 2023, 9:39am UTC](https://community.dynatrace.com/t/access-event-data-or-results-from-a-previous-workflow-step/39863/2 "2023-05-23T09:39:44Z")

</div>

Data can be accessed from any previous task in a workflow, and it doesn’t have to be its immediate predecessor.

All workflow task results are automatically available without any additional configuration. Access to data is given via the jinja2 expression, the same system and syntax that you might know from solutions like Red Hat Ansible.

Ad-hoc scripts (JavaScript action) has jinja2 expression disabled to mitigate the risk of possible code injections.&nbsp; For these, we provide access to the data via JavaScript SDKs.

---

<div class="post-metadata">

**Author:** ![adam\_gardner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/adam_gardner/32/20087_2.png) [@adam\_gardner](https://community.dynatrace.com/u/adam_gardner)\
**Post date:** [February 13, 2025, 6:54am UTC](https://community.dynatrace.com/t/access-event-data-or-results-from-a-previous-workflow-step/39863/3 "2025-02-13T06:54:12Z")

</div>

For anyone else looking for a code snippet, give a trigger + HTTP task called `get_foo`, you can retrieve the results of `get_foo` in a subsequent task like this:

```markup
import { execution } from '@dynatrace-sdk/automation-utils';
import { logsClient } from "@dynatrace-sdk/client-classic-environment-v2";

export default async function ({ executionId }) {
  const ex = await execution(executionId);
  console.log('Automated script execution on behalf of', ex.trigger);

  const result = await ex.result('get_foo');

  // Endpoint returns a JSON response
  // Get JSON
  const result_json = result['json'];

  // Get the `Answer` field from returned JSON
  const json_answer = result['json']['Answer'];

  console.log(json_answer);
  // Send a log line back into Dynatrace
  // Retrieve with DQL
  // fetch logs | filter contains(content, "644des93")
  logsClient.storeLog({"type": "text/plain; charset=utf-8", "body": "Some log content: a user ID: 644des93"});

  return { triggeredBy: ex.trigger };
}

```

 ![adam_gardner_0-1739429380576.png](https://global.discourse-cdn.com/dynatrace/original/3X/4/1/414b73e509362d986d9246ff59ee24c5c3310619.png)
