cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get result from previous task in a workflow ?

AurelienGravier
DynaMight Champion
DynaMight Champion

Hello,

 

In my workflow, I have a previous http request task with the following result :

AurelienGravier_4-1720692535978.png

 

I tried to use the value of "name" on the next task (http request) without success :

{
"eventType": "CUSTOM_INFO",
"title": "Loadtest start",
"timeout": 30,
"entitySelector": "type(APPLICATION),entityName.equals(XXXXXX)",
"properties": {
"Tool": "Octoperf",
"Load per minute": "100",
"Scenario name": "{{ result("launch_XXXXXXX_test2")["name"] }}"
}
}

 

I also tried with success :

"Scenario name": "{{ result("launch_XXXXXXX_test2")["json"]["name"] }}"

 

The error encountered is :

AurelienGravier_3-1720692441219.png

 

Could you help me how to get the right value from a task result ?

 

Thank you for your support.
Regards Aurélien

 

Observability consultant - Dynatrace Associate/Pro/Services certified
5 REPLIES 5

AurelienGravier
DynaMight Champion
DynaMight Champion

I solve it by using :

"Scenario name": "{{ result('launch_XXXX_test2').json.name }}"

 

Observability consultant - Dynatrace Associate/Pro/Services certified

AurelienGravier
DynaMight Champion
DynaMight Champion

But I don't find how to extract the name value with a custom JS task :

AurelienGravier_0-1720706208808.png

I encounter the exception below :

An error of type UNCAUGHT_EXCEPTION occurred in line 8 (col 39) " const name = await checkResult.json.name;": TypeError: Cannot read properties of undefined (reading 'name')
at default (file:///script.ts:8:39)
at eventLoopTick (ext:core/01_core.js:169:7)

 


Thank you.

Observability consultant - Dynatrace Associate/Pro/Services certified

Solved too !

// import of sdk modules
import { execution } from '@dynatrace-sdk/automation-utils';

export default async function ({ execution_id }) {
  const exe = await execution(execution_id);
  const checkResult = await exe.result('launch_xxxxx_test');


  const json = checkResult['json'];
  
  console.log('name : ', json.name);
  console.log('id : ', json.benchResultIds[0]);

}

 

Observability consultant - Dynatrace Associate/Pro/Services certified

@AurelienGravier ,

Can you help me on my thread.

And also I don't know why I'm seeing different output for my HTTP request.

Your output,

AK_1-1723928719992.png

My output,

AK_0-1723928683452.png

Regards,

AK

AurelienGravier
DynaMight Champion
DynaMight Champion

Hello @AK 

I think you found it by yourself.

However, based on my previous comment, I would have done it like this. :

// 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 json = data['0'];
  console.log('appId : ', json.scope);
}

Which "check_rum_version" is the name of the step corresponding to the http call.

Regards

Observability consultant - Dynatrace Associate/Pro/Services certified

Featured Posts