02 Apr 2024
05:52 PM
- last edited on
03 Apr 2024
11:00 AM
by
Michal_Gebacki
Hello, good day, I am starting to work with the workflows, in the example that I am building I make an http request, which results in a JSON file, which is what interests me since it brings all the data I need, my question is how can I get that json and work on it in the next task, I was reviewing the documentation and I see a result function but I can't quite understand how it works, I don't know if anyone has a similar example, thank you very much in advance
Solved! Go to Solution.
02 Apr 2024 10:45 PM
Hola Jorge, let me see if I can help a bit.
You can access the results of the previous steps using the following expressions:
https://docs.dynatrace.com/docs/shortlink/automation-workflow-expression-reference#result
You can use this syntaxis inside the options and parameters of the following steps.
If the returned object has attributes or more properties you can access them as well using something like:
{{ result('task_1').foo }}
Works as well when working with JSON objects. Most of the tasks return a JSON result object.
If you need to work with the previous results inside a Javascript task and code, you can work with something like in this example:
https://docs.dynatrace.com/docs/shortlink/davis-workflow-integration#evaluate
As you can see you can store the resulting object from a previous task, or even create a new array to store the whole results. In that example they use:
const TASK_ID = 'predict_disk_capacity'; //here you put the name of the previous task
const predResult = await exe.result(TASK_ID); //store the whole result in a new variable
const result = predResult['result']; //a new variable to store only the result part
Then you can work with result to traverse it or access any particular value.
Best regards,
Jose David.
01 Apr 2025 04:31 PM
Hey all, I am following up on this thread. I am working on creating a workflow that automatically queries the Dynatrace Dashboards API. That will get a list of dashboards and their respective IDs. I want to then take it and get all the dashboard JSON files to then upload them to gitlab.
I am currently getting the full list of dashboards, but I am having trouble taking that "dashboards.json" file and passing it to the next task. I have uploaded the json in the result in the following task. I have added a screenshot here. Let me know if anyone else has tried to do this!