30 Apr 2026 11:27 PM
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.The second task is to transform the JSON response into a table that is understandable and can be sent by email.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.
Solved! Go to Solution.
01 May 2026 09:01 AM
Hello @AntonioLara,
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:
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 😁
05 May 2026 08:41 PM
Hola
el resultado del correo se ve asi
05 May 2026 10:33 PM
Hello @AntonioLara!
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 😁
05 May 2026 10:37 PM
The documentation is Here
05 May 2026 11:42 PM
Excelent thanks
05 May 2026 09:20 PM
Is it possible to view this in a more understandable table format?
Featured Posts