Automations
All questions related to Workflow Automation, AutomationEngine, and EdgeConnect, as well as integrations with various tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I get the previous result from a Javascript task in Workflows?

badgerfifteen
Organizer

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?

1 REPLY 1

badgerfifteen
Organizer

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