02 Mar 2026 12:54 PM
Hi, I have some Javascript code which gets the current date and formats it into two-digit segments.
Example: 260301
This is the code:
// optional import of sdk modules
import { execution } from '@dynatrace-sdk/automation-utils';
export default async function () {
const now = new Date();
// Extract parts
const year = String(now.getFullYear()).slice(-2); // last 2 digits
const month = String(now.getMonth() + 1).padStart(2, "0"); // months are 0‑indexed
const day = String(now.getDate()).padStart(2, "0");
const formatted = `${year}${month}${day}`;
console.log(formatted); // e.g., "260302"
return formatted;
}I am trying to use it in the next task that I have. However, it always turns up blank with just the squiggly brackets only.
From the documentation, it said to use something like this:
{{ result('date') }}where 'date' is the name of the previous task/function. Any ideas?
Solved! Go to Solution.
02 Mar 2026 02:44 PM
I think I sorted it. It seems I have to create a duplicate task in the workflow for the result to be registered as a selectable option.
Featured Posts