05 Jun 2024 10:31 PM
Hello,
Maybe I am overlooking, but how can I add parameters to the API to start a workflow?
And how do I consume these parameters in js?
KR Henk
Solved! Go to Solution.
06 Jun 2024 10:21 AM
Hi @henk_stobbe
as mentioned in help, have you checked out swagger about how to add parameters to the workflow execution?
To access the input parameters, please have a look at this is the code snippet:
// optional import of sdk modules
import { execution } from '@dynatrace-sdk/automation-utils';
export default async function ({ execution_id }) {
// your code goes here
// e.g. get the current execution
const ex = await execution(execution_id);
console.log('Automated script execution on behalf of', ex.trigger);
console.log(ex.input);
console.log(ex.params);
return { triggeredBy: ex.trigger };
}
The parameters in that case will be logged to console.
Best,
Sini
06 Jun 2024 10:40 AM
Hi Sini,
Thanks for your reply, I am very happy,
KR Henk
10 Jun 2024 08:56 AM - edited 10 Jun 2024 08:56 AM
I'd like to add that you can also access workflow inputs in any action without javascript using expressions as well https://docs.dynatrace.com/docs/shortlink/automation-workflow-expression-reference#execution
# access the current execution object
{{ execution() }}
# access ID of current execution
Execution ID {{ execution().id }}
# access input of current execution
Execution input {{ execution().input | default('no input defined') }}