# Javascript action to write result of DQL query to file in a workflow, and then load that data in a Notebook via Javascript action?

**URL:** <https://community.dynatrace.com/t/javascript-action-to-write-result-of-dql-query-to-file-in-a-workflow-and-then-load-that-data-in-a-notebook-via-javascript-action/51647>\
**Category:** DQL\
**Tags:** dql, javascript\
**Created:** [May 14, 2025, 11:45pm UTC](https://community.dynatrace.com/t/javascript-action-to-write-result-of-dql-query-to-file-in-a-workflow-and-then-load-that-data-in-a-notebook-via-javascript-action/51647 "2025-05-14T23:45:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FShimaya](https://avatars.discourse-cdn.com/v4/letter/f/c6cbf5/32.png) [@FShimaya](https://community.dynatrace.com/u/FShimaya)\
**Post date:** [May 14, 2025, 11:45pm UTC](https://community.dynatrace.com/t/javascript-action-to-write-result-of-dql-query-to-file-in-a-workflow-and-then-load-that-data-in-a-notebook-via-javascript-action/51647/1 "2025-05-14T23:45:48Z")

</div>

Is it possible to create a workflow where the result of a DQL query is passed to a Javascript action, and that action writes the result to a file somewhere (assume this is SaaS), and then a Notebook displays the data from that file via a javascript action?&nbsp; The usecase is to have the workflow query a lot of data at night, write it to a file, and then have it available for viewing in a Notebook.&nbsp; I’d like to see sample code if this is possible.

---

<div class="post-metadata">

**Author:** ![marco\_irmer](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/marco_irmer/32/3038_2.png) [@marco\_irmer](https://community.dynatrace.com/u/marco_irmer)\
**Post date:** [May 16, 2025, 10:29pm UTC](https://community.dynatrace.com/t/javascript-action-to-write-result-of-dql-query-to-file-in-a-workflow-and-then-load-that-data-in-a-notebook-via-javascript-action/51647/2 "2025-05-16T22:29:45Z")

</div>

When a DQL query is executed as part of a workflow, the results are already stored as part of the workflow execution. You can just use the existing ‘executionsClient’ module from the automation-client SDK within a ‘Code’ tile to do the following:

1. Get the execution ID from the most recent execution of your workflow

2. Use the execution ID from step 1 above to then retrieve the results from the specific workflow step within that particular execution.

The resulting code looks like this:

```javascript
import { executionsClient } from "@dynatrace-sdk/client-automation";

export default async function () {

  // Get the last successful execution of the workflow
  const workflow_executions = await executionsClient.getExecutions({
    workflow: "<workflow_id_here>",
    ordering: "-endedAt",
    state: "SUCCESS"
  });
  const last_execution = workflow_executions.results[0].id;

  // fetch the result(s) from the workflow task
  const myData = await executionsClient.getTaskExecutionResult({
    executionId: last_execution,
    id: "<step_name_here>"
    });

  return myData;

}

```

---

<div class="post-metadata">

**Author:** ![FShimaya](https://avatars.discourse-cdn.com/v4/letter/f/c6cbf5/32.png) [@FShimaya](https://community.dynatrace.com/u/FShimaya)\
**Post date:** [May 19, 2025, 2:19pm UTC](https://community.dynatrace.com/t/javascript-action-to-write-result-of-dql-query-to-file-in-a-workflow-and-then-load-that-data-in-a-notebook-via-javascript-action/51647/3 "2025-05-19T14:19:50Z")

</div>

Thank you Marco. &nbsp;How do you export the result into a file (assuming this is SaaS) with data spanning the last 3 months, and then have a notebook or dashboard load those results from the file into tables and charts at a later time? &nbsp; &nbsp;For example, the workflow would kick off at 12 AM and write the results to a file. &nbsp;Then, users can later view the results in a dashboard or notebook.

---

<div class="post-metadata">

**Author:** ![marco\_irmer](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/marco_irmer/32/3038_2.png) [@marco\_irmer](https://community.dynatrace.com/u/marco_irmer)\
**Post date:** [May 19, 2025, 7:15pm UTC](https://community.dynatrace.com/t/javascript-action-to-write-result-of-dql-query-to-file-in-a-workflow-and-then-load-that-data-in-a-notebook-via-javascript-action/51647/4 "2025-05-19T19:15:52Z")

</div>

Dynatrace SaaS doesn’t currently provide any built-in storage of ‘files’ in the traditional sense. It sounds as though you are looking to visualize workflow output across several months, so perhaps your workflow could use the ‘S3: Put Object’ action to store the data in an S3 bucket, and then you can retrieve the data at a later date via another workflow or via a code tile within your notebook/dashboard.
