# Davis needs time to store events and problems after the workflow has triggered

**URL:** <https://community.dynatrace.com/t/davis-needs-time-to-store-events-and-problems-after-the-workflow-has-triggered/46633>\
**Category:** Automations\
**Tags:** integrations, workflows, automations\
**Created:** [July 16, 2024, 4:45pm UTC](https://community.dynatrace.com/t/davis-needs-time-to-store-events-and-problems-after-the-workflow-has-triggered/46633 "2024-07-16T16:45:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [July 16, 2024, 4:45pm UTC](https://community.dynatrace.com/t/davis-needs-time-to-store-events-and-problems-after-the-workflow-has-triggered/46633/1 "2024-07-16T16:45:07Z")

</div>

Hello,

when a Event or problem workflow is triggered, I you try to do a dql query to retrieve the attached&nbsp; problem or events resp. It seems these are not yet available.

After sometime when you run the workflow again retrieving the events attached to a problem and retrieving the problem attached to an event gives no issue;s.

Who knows the wait time before Davis has added these records to a bucket, after a trigger?

KR Henk

---

<div class="post-metadata">

**Author:** ![christian\_kreuz](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/christian_kreuz/32/21669_2.png) [@christian\_kreuz](https://community.dynatrace.com/u/christian_kreuz)\
**Post date:** [July 25, 2024, 10:32am UTC](https://community.dynatrace.com/t/davis-needs-time-to-store-events-and-problems-after-the-workflow-has-triggered/46633/2 "2024-07-25T10:32:15Z")

</div>

It should only take 10 seconds from Workflow being triggered by an Event (this is done internally), to the Event appearing in Grail.

I would recommend adding a Run JavaScript step with

```javascript
export default async function ({ execution_id }) {
  console.log('Starting to sleep');
  const milliseconds = 15000; // sleep time
  await new Promise(resolve => setTimeout(resolve, milliseconds));
  console.log('Done sleeping');
}

```

before the actual DQL statement.

In addition, a built-in “delay” feature for Workflows is planned.

---

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [July 25, 2024, 10:45am UTC](https://community.dynatrace.com/t/davis-needs-time-to-store-events-and-problems-after-the-workflow-has-triggered/46633/3 "2024-07-25T10:45:54Z")

</div>

Hi Christian,

FYI this is how my WF looks (-; creating the 5 mins delay!

I will retry to skip the two delay scripts and limit the wait in the main part see what happens. (also I will use the Promise ,&nbsp; great reminder)

Again thanks for your help!

 ![henk_stobbe_0-1721904045739.png](https://global.discourse-cdn.com/dynatrace/original/3X/e/4/e47251316c8a72ea392b0839560ce32f197e8244.png)

---

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [July 25, 2024, 11:10am UTC](https://community.dynatrace.com/t/davis-needs-time-to-store-events-and-problems-after-the-workflow-has-triggered/46633/4 "2024-07-25T11:10:31Z")

</div>

Hi Christian,

Very small remark/question: I assume all workflow task are separated, I mean the next step will only start if the previous is finished?

KR Henk

---

<div class="post-metadata">

**Author:** ![christian\_kreuz](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/christian_kreuz/32/21669_2.png) [@christian\_kreuz](https://community.dynatrace.com/u/christian_kreuz)\
**Post date:** [July 25, 2024, 11:26am UTC](https://community.dynatrace.com/t/davis-needs-time-to-store-events-and-problems-after-the-workflow-has-triggered/46633/5 "2024-07-25T11:26:43Z")

</div>

Looking at your screenshot, those tasks should be running in sequence, not parallel.

However, within a single JavaScript task, some things can run parallel, for instance:

```markup
export default async function ({ execution_id }) {
  console.log('Starting...');
  setTimeout(() => { console.log('First'); }, 1000);
  setTimeout(() => { console.log('Second'); }, 500);
  console.log('Done!');
}

```

This code sample will lead to an unexpected output of

```markup
Starting...
Done!
Second
First

```

you need to use await and a promise to make it right here:

```markup
export default async function ({ execution_id }) {
  console.log('Starting...');
  await new Promise(resolve => setTimeout(() => { console.log('First'); resolve(); }, 1000));
  await new Promise(resolve => setTimeout(() => { console.log('Second'); resolve(); }, 500));

  console.log('Done!');
}

```

and you will get the expected output of Starting…, First, Second and Done.

---

<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:** [July 25, 2024, 11:29am UTC](https://community.dynatrace.com/t/davis-needs-time-to-store-events-and-problems-after-the-workflow-has-triggered/46633/6 "2024-07-25T11:29:07Z")

</div>

FYI: we just added another task option to make a task wait a user defined time before executing..This will become available in the upcoming weeks and should make this a lot easier.
