<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Accessing event data or results from a previous workflow step in Automations</title>
    <link>https://community.dynatrace.com/t5/Automations/Access-event-data-or-results-from-a-previous-workflow-step/m-p/269958#M2045</link>
    <description>&lt;P&gt;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:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;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 };
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="adam_gardner_0-1739429380576.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/26390i51C6A446A405498E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="adam_gardner_0-1739429380576.png" alt="adam_gardner_0-1739429380576.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 16 Feb 2025 23:28:06 GMT</pubDate>
    <dc:creator>adam_gardner</dc:creator>
    <dc:date>2025-02-16T23:28:06Z</dc:date>
    <item>
      <title>Access event data or results from a previous workflow step</title>
      <link>https://community.dynatrace.com/t5/Automations/Access-event-data-or-results-from-a-previous-workflow-step/m-p/212876#M107</link>
      <description>&lt;P&gt;How do I access event data or results from a previous workflow step?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 11:47:59 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/Access-event-data-or-results-from-a-previous-workflow-step/m-p/212876#M107</guid>
      <dc:creator>AgataWlodarczyk</dc:creator>
      <dc:date>2023-07-20T11:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing event data or results from a previous workflow step</title>
      <link>https://community.dynatrace.com/t5/Automations/Access-event-data-or-results-from-a-previous-workflow-step/m-p/212881#M108</link>
      <description>&lt;P&gt;&lt;SPAN data-contrast="auto"&gt;Data can be accessed from any previous task in a workflow, and it doesn’t have to be its immediate predecessor. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-contrast="auto"&gt;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.&lt;/SPAN&gt;&lt;SPAN data-ccp-props="{}"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-contrast="auto"&gt;Ad-hoc scripts (JavaScript action) has jinja2 expression disabled to mitigate the risk of possible code injections.&amp;nbsp; For these, we provide access to the data via JavaScript SDKs.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 09:39:44 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/Access-event-data-or-results-from-a-previous-workflow-step/m-p/212881#M108</guid>
      <dc:creator>michaelwinkler</dc:creator>
      <dc:date>2023-05-23T09:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing event data or results from a previous workflow step</title>
      <link>https://community.dynatrace.com/t5/Automations/Access-event-data-or-results-from-a-previous-workflow-step/m-p/269958#M2045</link>
      <description>&lt;P&gt;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:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;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 };
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="adam_gardner_0-1739429380576.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/26390i51C6A446A405498E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="adam_gardner_0-1739429380576.png" alt="adam_gardner_0-1739429380576.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Feb 2025 23:28:06 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/Access-event-data-or-results-from-a-previous-workflow-step/m-p/269958#M2045</guid>
      <dc:creator>adam_gardner</dc:creator>
      <dc:date>2025-02-16T23:28:06Z</dc:date>
    </item>
  </channel>
</rss>

