Skip to main content
Version: 4.7.0

wfa

The wfa (Workflow Automation) namespace provides the core building blocks for defining Flows and Subflows. Use wfa.trigger() to start a flow, wfa.action() to execute built-in actions, and wfa.flowLogic for control flow (if/elseIf/else, forEach, doInParallel, tryCatch, appendToFlowVariables).

import { wfa } from '@servicenow/sdk/automation'

Members

MemberDescription
flowLogicControl flow operators for branching, looping, and flow control (if, elseIf, else, forEach, setFlowVariables, assignSubflowOutputs, endFlow, exitLoop, skipIteration, doInParallel, tryCatch, appendToFlowVariables).
actionExecute a built-in action step and capture its typed outputs. Pass an action definition from the action built-ins.
approvalDueDateDefine a due-date policy for an action.core.askForApproval step.
approvalRulesBuild a structured approval rules configuration for action.core.askForApproval.
dataPillCreate a typed data pill reference to a prior step's output or trigger data.
inlineScriptDefine a server-side script inline as an action or subflow input.
subflowInvoke a defined Subflow from inside a Flow or another Subflow. Pass an exported subflow constant and its inputs.
actionStepEmbed an OOB step inside a custom Action body. Pass a step definition from the actionStep built-ins.
assignActionOutputsAssign output values inside a custom action body. Maps declared outputs to actual values or datapill references.
errorEvaluationDefine error evaluation conditions for a custom action. Conditions are evaluated in order; the first match sets the action's status.
stageActivate a declared stage in the flow body. Pass a stage from params.stages.<key>. See FlowStage for stage declaration.
triggerRegister the trigger that starts the flow. Pass a trigger definition from the trigger built-ins.

Examples

Basic Flow

import { Flow, wfa, trigger, action } from '@servicenow/sdk/automation'

export default Flow(
{ $id: Now.ID['my-flow'], name: 'My Flow' },
wfa.trigger(
trigger.record.created,
{ $id: Now.ID['my-flow-trigger'] },
{ table: 'incident' }
),
(params) => [
wfa.action(
action.core.log,
{ $id: Now.ID['my-flow-log'] },
{ log_level: 'info', log_message: 'New incident created' }
),
]
);