Automation Utils
Utility functions for accessing AutomationEngine APIs from the Run JavaScript action.
npm install @dynatrace-sdk/automation-utils
Functions
actionExecution
Retrieves the action execution details for the current workflow.
Parameters
Name | Type | Description |
---|---|---|
id | string | The ID of the action execution to retrieve. If not provided, the ID from the caller service metadata is used. |
Returns
Description |
---|
The action execution details. |
Code example
//To get current action execution detail
import { actionExecution } from '@dynatrace-sdk/automation-utils';
const actionExe = await actionExecution();
Code example
//To get loopItem from current action execution
import { actionExecution } from '@dynatrace-sdk/automation-utils';
const actionExe = await actionExecution();
const loopItem = actionExe.loopItem;
// or
const { loopItem } = actionExe;
execution
Retrieves the execution details for the current workflow.
Parameters
Name | Type | Description |
---|---|---|
id | string | The ID of the execution to retrieve. If not provided, the ID from the caller service metadata is used. |
Returns
Description |
---|
The execution details. |
Code example
//To get current execution detail
import { execution } from '@dynatrace-sdk/automation-utils';
const exe = await execution();
Code example
//To get event context from current execution
import { execution } from '@dynatrace-sdk/automation-utils';
const exe = await execution();
const eventContext = exe.event();
Code example
//To get current task execution result
import { execution } from '@dynatrace-sdk/automation-utils';
const exe = await execution();
const result = await exe.result();
getExecutionLink
Returns
Description |
---|
The link to a workflow execution, or null if called within a simple workflow or outside a workflow. |
getTaskExecutionLink
Returns
Description |
---|
The link to a workflow execution, including the currently executed task name, or null if called within a simple workflow or outside a workflow. |
getWorkflowLink
Returns
Description |
---|
The link to a workflow, or null if called outside a workflow. |
result
Retrieves the result of a task execution in the current workflow.
Parameters
Name | Type | Description |
---|---|---|
predecessorTaskName*required | string | The name of the predecessor task. |
Returns
Description |
---|
The result of the predecessor task execution. |
Code example
//To get a predecessor task execution's result
import { result } from '@dynatrace-sdk/automation-utils';
const taskExecutionResult = await result('predecessor_task_1');
Constants
actionExecutionId
ID of the running action execution.
executionId
ID of the running execution.
taskName
Name of the running task.
workflowId
ID of the running workflow.
Types
IExecution
Extended execution type. Adds helper methods to the base Execution:
- IExecution.result—retrieve the result of a task execution.
- IExecution.event—get the event payload context of the execution.
Properties
Name | Type | Description |
---|---|---|
actor*required | string | |
endedAt | null | Date | |
eventTrigger | null | string | |
id*required | string | |
input | ExecutionInput | |
isDraft | boolean | |
params | ExecutionParams | |
parentExecution*required | null | string | |
parentTaskName*required | null | string | Parent task execution's name (subworkflows only) |
providedInput | null | ExecutionProvidedInput | |
rootExecution | null | string | |
rootWorkflow | null | string | |
runtime*required | number | Calculate the runtime of an execution in seconds. If the execution is not ended, runtime is calculated until now. |
schedule | null | string | |
startedAt | Date | |
state*required | "ERROR" | "RUNNING" | "SUCCESS" | "UNKNOWN" | "PAUSED" | "CANCELLED" | |
stateInfo | null | string | |
title*required | string | |
trigger | null | string | |
triggerType*required | "Manual" | "Schedule" | "Event" | "Workflow" | |
triggerTypeDetail | TriggerTypeDetail | |
user | null | string | |
workflow*required | string | Executed Workflow |
workflowType*required | "STANDARD" | "SIMPLE" | |
workflowVersion*required | null | number |
Methods
event
Returns the event context payload associated with the execution.
Returns
Description |
---|
A key-value object if event data is available, otherwise null . |
Code example
import { execution } from '@dynatrace-sdk/automation-utils';
const exe = await execution();
const eventContext = exe.event();
result
Retrieves the result of a task execution.
Parameters
Name | Type | Description |
---|---|---|
taskId*required | string | The ID of the task whose result should be retrieved. |
Returns
Description |
---|
A promise resolving with the task execution result. |
Code example
import { execution } from '@dynatrace-sdk/automation-utils';
const exe = await execution();
const result = await exe.result("task-id");