# Workflow - transform the JSON response into a table that is understandable and can be sent by email

**URL:** <https://community.dynatrace.com/t/workflow-transform-the-json-response-into-a-table-that-is-understandable-and-can-be-sent-by-email/55773>\
**Category:** Automations\
**Tags:** dql, workflows\
**Created:** [April 30, 2026, 10:27pm UTC](https://community.dynatrace.com/t/workflow-transform-the-json-response-into-a-table-that-is-understandable-and-can-be-sent-by-email/55773 "2026-04-30T22:27:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![AntonioLara](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@AntonioLara](https://community.dynatrace.com/u/AntonioLara)\
**Post date:** [April 30, 2026, 10:27pm UTC](https://community.dynatrace.com/t/workflow-transform-the-json-response-into-a-table-that-is-understandable-and-can-be-sent-by-email/55773/1 "2026-04-30T22:27:54Z")

</div>

Hello, I have this workflow that runs every 5 minutes. The first task is to perform a DQL query to retrieve the issues that have been active in the last 24 hours.&nbsp;The second task is to transform the JSON response into a table that is understandable and can be sent by email.&nbsp;This is where it fails.I’ve attached the workflow so you can guide me on how to send the results by email in a table format. Thank you.  
[pruebas.workflow.json](https://community.dynatrace.com/uploads/short-url/mjYys2tPjCdVOMHCRZzewzs0ilP.json) (4.01 KB)

 ![image.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/6/06fbe549a0add5c3ec7d72d3dbe44ffeaf7890f9.png)  
 ![{AFFCEA6D-DF92-408B-8D95-FE86E2D4F251}.png](https://global.discourse-cdn.com/dynatrace/original/2X/4/4e97c0d502426d82c94b18a679913893811b392c.png)  
 ![image.png](https://global.discourse-cdn.com/dynatrace/original/3X/a/2/a2ee25c29c605113037972ae034d1452d0510101.png)

---

<div class="post-metadata">

**Author:** ![MaximilianoML](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/maximilianoml/32/25038_2.png) [@MaximilianoML](https://community.dynatrace.com/u/MaximilianoML)\
**Post date:** [May 1, 2026, 8:01am UTC](https://community.dynatrace.com/t/workflow-transform-the-json-response-into-a-table-that-is-understandable-and-can-be-sent-by-email/55773/2 "2026-05-01T08:01:50Z")

</div>

Hello [@AntonioLara](https://community.dynatrace.com/user/84803),

The important point here is that the Dynatrace Email action does not support HTML. It supports Markdown-style formatting, including tables, so the JavaScript task should return a Markdown table string, not an HTML table. Dynatrace documents that Email formatting supports tables, but HTML is not supported in the message body.

You can try to use this pattern:

```javascript
import { result } from '@dynatrace-sdk/automation-utils';

export default async function () {
  // Replace this with the exact task name of your DQL task
  const dqlResult = await result('execute_dql_query');

  // Depending on the DQL task result shape, records may be in one of these locations
  const rows =
    dqlResult.records ??
    dqlResult.result?.records ??
    dqlResult.data ??
    [];

  if (!rows || rows.length === 0) {
    return {
      subject: 'Dynatrace issues report - no active issues',
      body: 'No issues were found in the last 24 hours.'
    };
  }

  const escapeCell = (value) => {
    if (value === null || value === undefined) {
      return '';
    }

    return String(value)
      .replace(/\|/g, '\\|')
      .replace(/\n/g, ' ');
  };

  const tableRows = rows.map((row) => {
    return [
      escapeCell(row['display_id'] ?? row['event.id'] ?? row['problem.id'] ?? ''),
      escapeCell(row['event.name'] ?? row['problem.title'] ?? row['title'] ?? ''),
      escapeCell(row['event.status'] ?? row['status'] ?? ''),
      escapeCell(row['dt.entity.host'] ?? row['dt.entity.service'] ?? row['entity'] ?? ''),
      escapeCell(row['timestamp'] ?? row['start_time'] ?? '')
    ].join(' | ');
  });

  const markdownTable = [
    '| ID | Title | Status | Entity | Time |',
    '|---|---|---|---|---|',
    ...tableRows.map((r) => `| ${r} |`)
  ].join('\n');

  return {
    subject: `Dynatrace issues report - ${rows.length} issue(s) in the last 24h`,
    body: `# Dynatrace issues report\n\nIssues detected in the last 24 hours:\n\n${markdownTable}`
  };
}

```

I hope this helps you 😁

---

<div class="post-metadata">

**Author:** ![AntonioLara](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@AntonioLara](https://community.dynatrace.com/u/AntonioLara)\
**Post date:** [May 5, 2026, 7:41pm UTC](https://community.dynatrace.com/t/workflow-transform-the-json-response-into-a-table-that-is-understandable-and-can-be-sent-by-email/55773/3 "2026-05-05T19:41:40Z")

</div>

Hola

el resultado del correo se ve asi

 ![AntonioLara_0-1778010083324.png](https://global.discourse-cdn.com/dynatrace/original/2X/f/f6785cdbbfce768ddf306c6ebe562eb327f06e70.png)

---

<div class="post-metadata">

**Author:** ![AntonioLara](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@AntonioLara](https://community.dynatrace.com/u/AntonioLara)\
**Post date:** [May 5, 2026, 8:20pm UTC](https://community.dynatrace.com/t/workflow-transform-the-json-response-into-a-table-that-is-understandable-and-can-be-sent-by-email/55773/4 "2026-05-05T20:20:22Z")

</div>

Is it possible to view this in a more understandable table format?

---

<div class="post-metadata">

**Author:** ![MaximilianoML](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/maximilianoml/32/25038_2.png) [@MaximilianoML](https://community.dynatrace.com/u/MaximilianoML)\
**Post date:** [May 5, 2026, 9:33pm UTC](https://community.dynatrace.com/t/workflow-transform-the-json-response-into-a-table-that-is-understandable-and-can-be-sent-by-email/55773/5 "2026-05-05T21:33:39Z")

</div>

Hello [@AntonioLara](https://community.dynatrace.com/user/84803)!

Yeah, because you’re using the whole json object… you need to use only the Markdown part, so access the “body” and return the value (the markdown itself), you should be good to go. Let me know if it worked. P.s: If it helped you, please Kudo my replies, I’m aiming to be member of the month 😁

---

<div class="post-metadata">

**Author:** ![MaximilianoML](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/maximilianoml/32/25038_2.png) [@MaximilianoML](https://community.dynatrace.com/u/MaximilianoML)\
**Post date:** [May 5, 2026, 9:37pm UTC](https://community.dynatrace.com/t/workflow-transform-the-json-response-into-a-table-that-is-understandable-and-can-be-sent-by-email/55773/6 "2026-05-05T21:37:09Z")

</div>

The documentation&nbsp;is&nbsp;[Here](https://docs.dynatrace.com/docs/shortlink/automation-workflows-email#tables)

---

<div class="post-metadata">

**Author:** ![AntonioLara](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@AntonioLara](https://community.dynatrace.com/u/AntonioLara)\
**Post date:** [May 5, 2026, 10:42pm UTC](https://community.dynatrace.com/t/workflow-transform-the-json-response-into-a-table-that-is-understandable-and-can-be-sent-by-email/55773/7 "2026-05-05T22:42:39Z")

</div>

Excelent thanks
