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
3 REPLIES 3

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

Featured Posts