19 Jun 2024 12:32 PM
Solved! Go to Solution.
19 Jun 2024 12:55 PM
You can access task result data in other tasks using expressions, specifically the result expression https://docs.dynatrace.com/docs/shortlink/automation-workflow-expression-reference#result
In your example, you have a task "time_validation" with a result: records[{hour: 21, even....} .. ]
So in order to access the property hour in the first item of the records list, the expression would be
{{ result("execute_dql_query_1")["records"][0]["hour"] }}
Given that the DQL query records are always a list, you might want to loop over them and grab the hour, for example
{% for record in result("execute_dql_query_1")["records"] %}
My Hour : {{ record.hour }}
{% endfor %}
Those expression can be used in any task input of any action with the exception of custom javascript, as this could lead to unwanted code injection. Therefore there is a javascript native option to access task results described here: https://docs.dynatrace.com/docs/platform-modules/automations/workflows/default-workflow-actions/run-...
Note: in order to access task results, the source task needs to be a predecessor to the task where you reference its result. However it does not have to be the immediate predecessor. Assuming a linear workflow with 5 tasks, task 5 can still access any result from task 1-4.
19 Jun 2024 01:12 PM - edited 19 Jun 2024 01:14 PM
Thank you for your answer, however it gives me an error when calling the result of the previous task as proof I am calling the total value of the previous task "request_validation" as seen in the image, the error log tells me that the variable does not exist
19 Jun 2024 01:21 PM
the expression looks good. Can you share the exact error message?
Also to make sure the tasks have a dependency with each other, can you share the conditions tab from the time_validation task?
18 Dec 2024 03:07 PM
hi there, im facing the same issue when developing a workflow that must send an email when the JVM% threshold is reached. Im using a DQL query that brings records ( jvm metric from diferent processes) and what we must do is: if the metric of any of those processes is above 80%, send the email alert (on a next step we want to alert also through ansible) so far the the DQL gives me this data:
but when doing the condition on the next step it fails
im using the records variable from the last step that brings the 8 records but on the email step it shows othe info and doesnt work.
thanks in advance 🙂