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

**URL:** <https://community.dynatrace.com/t/how-do-i-get-the-previous-result-from-a-javascript-task-in-workflows/55154>\
**Category:** Automations\
**Tags:** workflows, automations\
**Created:** [March 2, 2026, 12:54pm UTC](https://community.dynatrace.com/t/how-do-i-get-the-previous-result-from-a-javascript-task-in-workflows/55154 "2026-03-02T12:54:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![badgerfifteen](https://avatars.discourse-cdn.com/v4/letter/b/e68b1a/32.png) [@badgerfifteen](https://community.dynatrace.com/u/badgerfifteen)\
**Post date:** [March 2, 2026, 12:54pm UTC](https://community.dynatrace.com/t/how-do-i-get-the-previous-result-from-a-javascript-task-in-workflows/55154/1 "2026-03-02T12:54:15Z")

</div>

Hi, I have some Javascript code which gets the current date and formats it into two-digit segments.

**Example: 260301**

This is the code:

```markup
// 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:

```markup
{{ result('date') }}

```

where ‘date’ is the name of the previous task/function. Any ideas?

---

<div class="post-metadata">

**Author:** ![badgerfifteen](https://avatars.discourse-cdn.com/v4/letter/b/e68b1a/32.png) [@badgerfifteen](https://community.dynatrace.com/u/badgerfifteen)\
**Post date:** [March 2, 2026, 2:44pm UTC](https://community.dynatrace.com/t/how-do-i-get-the-previous-result-from-a-javascript-task-in-workflows/55154/2 "2026-03-02T14:44:16Z")

</div>

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.
