# Help in writing a JS code for workflow

**URL:** <https://community.dynatrace.com/t/help-in-writing-a-js-code-for-workflow/47177>\
**Category:** Open Q&A\
**Tags:** workflows, javascript, dynatrace-api\
**Created:** [August 16, 2024, 1:22pm UTC](https://community.dynatrace.com/t/help-in-writing-a-js-code-for-workflow/47177 "2024-08-16T13:22:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/ak/32/164_2.png) [@AK](https://community.dynatrace.com/u/AK)\
**Post date:** [August 16, 2024, 1:22pm UTC](https://community.dynatrace.com/t/help-in-writing-a-js-code-for-workflow/47177/1 "2024-08-16T13:22:11Z")

</div>

Hi Folks,

Need some help in writing a JS code for workflow.

I’m using “Issue an HTTP request to any API” call to fetch the response and I wanted to objects from this response to next&nbsp;“Issue an HTTP request to any API” call.

As far as I know, we cannot pass objects directly from “Issue an HTTP request to any API” call to next step/call. We have to use “Build a custom task running js Code” to store the values/objects and use for next step or API call.

The body for first API call comprises of,

```markup
{
    "objectId": "abscdf",
    "summary": "",
    "searchSummary": "",
    "created": 12345677,
    "modified": 78901234,
    "createdBy": "elstfsvs",
    "modifiedBy": "elstfsvs",
    "author": "someone@test.com",
    "updateToken": "123456absbdsld",
    "scope": "APPLICATION-123456xyz",
    "schemaId": "builtin:rum.web.rum-javascript-updates",
    "schemaVersion": "1.1",
    "resourceContext": {
        "operations": [
            "read",
            "write",
            "delete"
        ],
        "modifications": {
            "movable": true,
            "modifiablePaths": [],
            "nonModifiablePaths": []
        }
    },
    "value": {
        "JavascriptVersion": "CUSTOM"
    }
}

```

Based on&nbsp;_ **JavascriptVersion,** &nbsp;_I wanted to pass application ID to next request which is actually POST api call.

I tried to write the below JS code, I’m able to get whole response body but how do I get those objects and pass it on to next API call.

```markup
// optional import of sdk modules
import { execution } from '@dynatrace-sdk/automation-utils';
  export default async function({execution_id}) {
  const ex = await execution(execution_id); 
  const data = await ex.result('check_rum_version');
  console.log(data);
}

```

Can someone help here.

Regards,

AK

---

<div class="post-metadata">

**Author:** ![AK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/ak/32/164_2.png) [@AK](https://community.dynatrace.com/u/AK)\
**Post date:** [August 16, 2024, 9:14pm UTC](https://community.dynatrace.com/t/help-in-writing-a-js-code-for-workflow/47177/2 "2024-08-16T21:14:27Z")

</div>

Can somebody please share some thoughts on this.

---

<div class="post-metadata">

**Author:** ![AK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/ak/32/164_2.png) [@AK](https://community.dynatrace.com/u/AK)\
**Post date:** [August 18, 2024, 6:30pm UTC](https://community.dynatrace.com/t/help-in-writing-a-js-code-for-workflow/47177/3 "2024-08-18T18:30:15Z")

</div>

I’m able to get this with below code.

```markup
// optional import of sdk modules
import { execution } from '@dynatrace-sdk/automation-utils';
  export default async function({execution_id}) {
  const ex = await execution(execution_id); 
  const data = await ex.result('check_rum_version');
  const Scope = data[0].json.scope;
  return Scope;
  console.log(Scope);
}

```

Regards,

AK
