18 Jun 2024 08:15 AM - edited 18 Jun 2024 08:29 AM
Good morning,
As shown below, it would be nice to use variables in the http request:
So my questions is this possible, or do I need to write my own fetch request?
And I assume you need multiple returns for multiple variables or is the proper way state or document?
In short what is the proper way for this?
KR Henk
Solved! Go to Solution.
18 Jun 2024 09:00 AM
You can use the expressions documented at https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference as well as any default jinja2 function (link in the doc).
We currently do not support defining a fixed set of variables on the workflow to use anywhere (although on the roadmap for this year with the proper introduction of workflow input support and default values in the UI).
For now, if you want to manage a set of variables in one place to use throughout the workflow, your best bet would be an ad-hoc javascript task that returns the desired data.
Return data can be any json object, so complex, nested objects with any json supported types are possible. for example:
export default async function ({ execution_id }) {
return {
my_string: "Some important string",
my_number: 42,
my_list: [1,2,"something else"],
my_object: {
my_key: "my value",
my_other_number: 196,
my_boolean: true
}
};
}
will return as shown
Then you can access the data using the result expression
{{ result("my_data_task")["my_object"]["my_key"] }}
Note: in order to get proper autocomplete suggestion for the results, you'll need to update the sample result of your custom javascript task accordingly.
You can find that on the Sample Result tab
Then Edit and update the content.
Best way to do this I suggest to run the workflow once first, check the task works as expected and then use the "Sample from task exeuction" button which automatically updates the sample result with the result from the last execution:
-----
Once we add full workflow input (and output) support, you will have a setting in the worklfow do define worklow scoped variables.
18 Jun 2024 09:06 AM
Great lesson thanks! (-;
18 Jun 2024 09:09 AM
Thanks for the question!