Hello Dynatrace family,
I have been having difficulty understanding how to interact with workflow tasks behavior and how to be able to control those behaviors.
I have a javascript code that checks if a variable that I captured from previous task matches it or not, if it doesn’t match I want my task to fail but It always ends up being successful even when the value doesn’t match with what I defined.
// optional import of sdk modules<br>import { execution } from '@dynatrace-sdk/automation-utils';<br>import { executionsClient } from '@dynatrace-sdk/client-automation';<br><br>export default async function ({ execution_id }) {<br>const ex = await execution(execution_id);<br>var results:JSON = await executionsClient.getTaskExecutionResult({ executionId: execution_id, id: "execute_dql_query_1" });<br>var driftResults = results.records;<br>let errorIdValue = driftResults[0].errorid;<br>function checkIfSpecificerrorid(value) {<br>const specificNumber = 6000;<br>const numericValue = Number(value);<br><br>if (numericValue !== specificNumber){<br>throw new Error("Value does not match " + specificNumber);<br>} <br>console.log("value matches the specific number: " + value);<br>}<br><br>try {<br>if (errorIdValue !== undefined) {<br>checkIfSpecificerrorid(errorIdValue);<br>}<br>} catch (error) {<br>console.error(error.message);<br>}<br>}
How can I make this code to fail the task rather than successfully complete?
Edit: the content of driftResults is :
[<br> {<br> "errorid" : "6001"<br> }<br>]

