<?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: Workflows Davis problem trigger in Automations</title>
    <link>https://community.dynatrace.com/t5/Automations/Workflows-Davis-problem-trigger/m-p/248422#M1613</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;Please try adding a sleep step in your JavaScript code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export default async function ({ execution_id }) {
  console.log('Starting to sleep');
  const milliseconds = 15000;
  await new Promise(resolve =&amp;gt; setTimeout(resolve, milliseconds));
  console.log('Done sleeping');
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It can take a couple of seconds for events (in this case a Davis Problem) to be query-able in Grail via DQL, whereas the Workflow is triggered immediately when we first see the event.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jun 2024 09:30:03 GMT</pubDate>
    <dc:creator>christian_kreuz</dc:creator>
    <dc:date>2024-06-17T09:30:03Z</dc:date>
    <item>
      <title>Workflows Davis problem trigger</title>
      <link>https://community.dynatrace.com/t5/Automations/Workflows-Davis-problem-trigger/m-p/248407#M1611</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Hello everyone, I'm starting out with automations with workflows. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I am making a worflow that, based on a Davis problem trigger, assigns a category between 3 levels that I have defined according to the time of day. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;For this I have the event trigger, as the first task I recover this information with a javascript code. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;import { execution } from '@dynatrace-sdk/automation-utils';
export default async function ({ execution_id }) {
  // your code goes here
  // e.g. get the current execution
  const ex = await execution(execution_id);
  const problem_event = ex.params.event

  console.log('Affected entity IDs', problem_event);
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;My problem is that I cannot find a way to call the information of the sfirst task in my second task with GQL code where based on the problem id I detect the problem and do the aggregation functions that I require by assigning a priority field. For Example(I still need to execute the aggregations but I have it clearer in dql than in javascript)&lt;/SPAN&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;fetch events, from:now()-6m
| filter event.kind == "DAVIS_PROBLEM"
| filter display_id==&amp;lt;id.problem_firstTask&amp;gt;
| fieldsAdd hour=formatTimestamp(timestamp,format:"H")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;The goal of this is to then be able to use this information in an integration with ServiceNow to generate Tk's.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2024 07:36:33 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/Workflows-Davis-problem-trigger/m-p/248407#M1611</guid>
      <dc:creator>JhonU</dc:creator>
      <dc:date>2024-06-17T07:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Workflows Davis problem trigger</title>
      <link>https://community.dynatrace.com/t5/Automations/Workflows-Davis-problem-trigger/m-p/248422#M1613</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;Please try adding a sleep step in your JavaScript code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export default async function ({ execution_id }) {
  console.log('Starting to sleep');
  const milliseconds = 15000;
  await new Promise(resolve =&amp;gt; setTimeout(resolve, milliseconds));
  console.log('Done sleeping');
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It can take a couple of seconds for events (in this case a Davis Problem) to be query-able in Grail via DQL, whereas the Workflow is triggered immediately when we first see the event.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2024 09:30:03 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/Workflows-Davis-problem-trigger/m-p/248422#M1613</guid>
      <dc:creator>christian_kreuz</dc:creator>
      <dc:date>2024-06-17T09:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: Workflows Davis problem trigger</title>
      <link>https://community.dynatrace.com/t5/Automations/Workflows-Davis-problem-trigger/m-p/248437#M1616</link>
      <description>&lt;P&gt;In order to make data available from a javascript task to its subsequent tasks, you need to return some data. This well then show up as a result on that task. In your example you could return the problem_event variable like so:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;import { execution } from '@dynatrace-sdk/automation-utils';
export default async function ({ execution_id }) {
  // your code goes here
  // e.g. get the current execution
  const ex = await execution(execution_id);
  const problem_event = ex.params.event

  console.log('Affected entity IDs', problem_event);

  // return data will show up as task result
  // return data should always be an object
  // eg return {"my_key": "my_value"}
  return problem_event
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;Task results can be used by follow-up tasks using expressions:&amp;nbsp;&lt;A href="https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference#result" target="_blank"&gt;Expression reference - Dynatrace Docs&lt;/A&gt;&lt;BR /&gt;So again for your example, assuming the first task is named "get_problem_details":&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;fetch events, from:now()-6m
| filter event.kind == "DAVIS_PROBLEM"
| filter display_id=="{{ result('get_problems_details')['display_id']}}"
| fieldsAdd hour=formatTimestamp(timestamp,format:"H")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;However if you simply need to access data from the event, you can also access this directly using the expressions as well&amp;nbsp;&amp;nbsp;&lt;A href="https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference#event" target="_blank"&gt;Expression reference - Dynatrace Docs&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;fetch events, from:now()-6m
| filter event.kind == "DAVIS_PROBLEM"
| filter display_id=="{{ event()['display_id'] }}"
| fieldsAdd hour=formatTimestamp(timestamp,format:"H")&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 17 Jun 2024 11:33:13 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/Workflows-Davis-problem-trigger/m-p/248437#M1616</guid>
      <dc:creator>ChristopherHejl</dc:creator>
      <dc:date>2024-06-17T11:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: Workflows Davis problem trigger</title>
      <link>https://community.dynatrace.com/t5/Automations/Workflows-Davis-problem-trigger/m-p/248460#M1617</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thanks so much, I am clearer about the use of reference expressions, I really didn't know how to integrate them into the gql codes.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2024 14:04:31 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/Workflows-Davis-problem-trigger/m-p/248460#M1617</guid>
      <dc:creator>JhonU</dc:creator>
      <dc:date>2024-06-17T14:04:31Z</dc:date>
    </item>
  </channel>
</rss>

