Skip to main content
Version: 4.7.0

trigger

Trigger definitions for starting a Flow. Pass a trigger as the first argument to wfa.trigger().

trigger.record

Triggers that fire in response to record lifecycle events.

KeyDescription
createdFires when a record is created on the specified table.
createdOrUpdatedFires when a record is created or updated on the specified table.
updatedFires when a record is updated on the specified table.

Usage Pattern

All record triggers follow this invocation shape:

wfa.trigger(
trigger.record.<triggerType>,
{ $id: Now.ID['trigger_id'] },
{
table: 'table_name',
condition: 'encoded_query',
// ... other configuration parameters
}
)

trigger.record.created

Activates when a new record is created in the specified table.

Configuration Parameters

ParameterTypeDefaultRequiredDescription
tablestring-YesTable to monitor for new records
conditionstring-NoEncoded query to filter which records trigger the flow
run_flow_in'any' | 'background' | 'foreground''any'NoExecution context for the flow
run_on_extended'true' | 'false''false'NoWhether to run on child tables
run_when_setting'both' | 'interactive' | 'non_interactive''both'NoSession type filter
run_when_user_setting'any' | 'one_of' | 'not_one_of''any'NoUser-based filter mode
run_when_user_liststring[][]NoList of user sys_ids for filtering

Output Fields

FieldTypeDescription
currentreferenceThe created record
table_namestringTable where record was created
run_start_timeglide_date_timeFlow execution start time
run_start_date_timeglide_date_timeFlow execution start date/time

trigger.record.updated

Activates when an existing record is updated in the specified table.

Configuration Parameters

ParameterTypeDefaultRequiredDescription
tablestring-YesTable to monitor for updated records
conditionstring-NoEncoded query to filter which records trigger the flow
run_flow_in'any' | 'background' | 'foreground''any'NoExecution context for the flow
run_on_extended'true' | 'false''false'NoWhether to run on child tables
run_when_setting'both' | 'interactive' | 'non_interactive''both'NoSession type filter
run_when_user_setting'any' | 'one_of' | 'not_one_of''any'NoUser-based filter mode
run_when_user_liststring[][]NoList of user sys_ids for filtering
trigger_strategy'once' | 'unique_changes' | 'every' | 'always''once'NoControls when trigger fires for updates

trigger_strategy Values

  • 'once' — Fires only the first time condition matches
  • 'unique_changes' — Fires for each unique change to monitored fields
  • 'every' — Fires on every update regardless of field changes
  • 'always' — Fires only if flow is not currently running

Output Fields

FieldTypeDescription
currentreferenceThe updated record (current state)
changed_fieldsarrayArray of changed field details with previous and current values
table_namestringTable where record was updated
run_start_timeglide_date_timeFlow execution start time
run_start_date_timeglide_date_timeFlow execution start date/time

changed_fields Structure

Each element of the changed_fields array has this shape:

{
field_name: string,
previous_value: string,
previous_display_value: string,
current_value: string,
current_display_value: string
}

trigger.record.createdOrUpdated

Activates when a record is either created or updated in the specified table.

Configuration Parameters

ParameterTypeDefaultRequiredDescription
tablestring-YesTable to monitor for created or updated records
conditionstring-NoEncoded query to filter which records trigger the flow
run_flow_in'any' | 'background' | 'foreground''any'NoExecution context for the flow
run_on_extended'true' | 'false''false'NoWhether to run on child tables
run_when_setting'both' | 'interactive' | 'non_interactive''both'NoSession type filter
run_when_user_setting'any' | 'one_of' | 'not_one_of''any'NoUser-based filter mode
run_when_user_liststring[][]NoList of user sys_ids for filtering
trigger_strategy'once' | 'unique_changes' | 'every' | 'always''once'NoControls when trigger fires for updates

trigger_strategy only affects updates -- creates always fire once. See trigger.record.updated → trigger_strategy Values for value descriptions.

Output Fields

FieldTypeDescription
currentreferenceThe created or updated record (current state)
changed_fieldsarrayArray of changed field details (only present for updates)
table_namestringTable where record was created or updated
run_start_timeglide_date_timeFlow execution start time
run_start_date_timeglide_date_timeFlow execution start date/time

Note: changed_fields is only populated when the trigger fires for an update. On record creation, changed_fields is empty or undefined -- check this to distinguish create from update.

trigger.scheduled

Triggers that fire on a time-based schedule.

KeyDescription
dailyFires once per day at the specified time.
monthlyFires once per month at the specified day and time.
repeatFires repeatedly at a configured interval.
runOnceFires once at a specific date and time.
weeklyFires once per week at the specified day and time.

Usage Pattern

All scheduled triggers follow this invocation shape:

wfa.trigger(
trigger.scheduled.<triggerType>,
{ $id: Now.ID['trigger_id'] },
{
// time-based configuration parameters
}
)

Note: Time and Duration are available globally from @servicenow/sdk/global -- do NOT import them from @servicenow/sdk/core.


trigger.scheduled.daily

Activates once per day at a specified time.

Configuration Parameters

ParameterTypeDefaultRequiredDescription
timeTime-YesTime of day to run (hours, minutes, seconds)

Time Constructor

Time(
{ hours: number, minutes: number, seconds: number },
timezone: string // e.g., 'UTC', 'America/Los_Angeles'
)

Output Fields

FieldTypeDescription
run_start_timeglide_date_timeFlow execution start time
run_start_date_timeglide_date_timeFlow execution start date/time

trigger.scheduled.weekly

Activates once per week on a specified day and time.

Configuration Parameters

ParameterTypeDefaultRequiredDescription
day_of_weekinteger-YesDay of week (1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, 6=Saturday, 7=Sunday)
timeTime-YesTime of day to run (hours, minutes, seconds)

day_of_week Values

  • 1 -- Monday
  • 2 -- Tuesday
  • 3 -- Wednesday
  • 4 -- Thursday
  • 5 -- Friday
  • 6 -- Saturday
  • 7 -- Sunday

Output Fields

FieldTypeDescription
run_start_timeglide_date_timeFlow execution start time
run_start_date_timeglide_date_timeFlow execution start date/time

trigger.scheduled.monthly

Activates once per month on a specified day and time.

Configuration Parameters

ParameterTypeDefaultRequiredDescription
day_of_monthinteger-YesDay of month (1-31) to run
timeTime-YesTime of day to run (hours, minutes, seconds)

Note: If day_of_month is greater than the number of days in the month (e.g., 31 for February), the flow runs on the last day of that month.

Output Fields

FieldTypeDescription
run_start_timeglide_date_timeFlow execution start time
run_start_date_timeglide_date_timeFlow execution start date/time

trigger.scheduled.repeat

Activates repeatedly at a specified interval.

Configuration Parameters

ParameterTypeDefaultRequiredDescription
repeatDuration-YesInterval duration between executions

Duration Constructor

Duration({
days?: number,
hours?: number,
minutes?: number,
seconds?: number
})

Output Fields

FieldTypeDescription
run_start_timeglide_date_timeFlow execution start time
run_start_date_timeglide_date_timeFlow execution start date/time

trigger.scheduled.runOnce

Activates once at a specified date and time.

Configuration Parameters

ParameterTypeDefaultRequiredDescription
run_indatetime-YesSpecific date and time to run the flow

run_in Format

Use ISO 8601 format: 'YYYY-MM-DD HH:MM:SS' (e.g., '2026-03-15 14:30:00').

Output Fields

FieldTypeDescription
run_start_timeglide_date_timeFlow execution start time
run_start_date_timeglide_date_timeFlow execution start date/time

trigger.application

Application-specific event triggers.

KeyDescription
inboundEmailFires when an inbound email is received.
knowledgeManagementFires on a Knowledge Management lifecycle event.
remoteTableQueryFires when a remote table query is executed.
serviceCatalogFires when a Service Catalog request item is submitted.
slaTaskFires on an SLA task event.

Usage Pattern

All application triggers follow this invocation shape:

wfa.trigger(
trigger.application.<triggerType>,
{ $id: Now.ID['trigger_id'] },
{
// application-specific configuration parameters
}
)

trigger.application.inboundEmail

Activates when an inbound email matches specified conditions.

Configuration Parameters

ParameterTypeDefaultRequiredDescription
email_conditionsstring-NoEncoded query conditions to filter emails
orderinteger-NoPriority order for this trigger (lower values = higher priority)
stop_condition_evaluationbooleantrueNoWhen true, stops processing after first matching trigger
target_tablestring-NoTable associated with reply record

Note: email_conditions uses LIKE (not CONTAINS) when filtering on text fields like subject or body. Email conditions follow ServiceNow encoded query format against sys_email fields.

Output Fields

FieldTypeDescription
inbound_emailreferenceReference to sys_email record
target_table_namestringTable name of the target record
body_textstring_full_utf8Email body content
subjectstring_full_utf8Email subject line
userreferenceUser who sent the email (sys_user reference)
target_recordreferenceRelated target record if applicable
from_addressstring_full_utf8Sender email address

trigger.application.slaTask

Activates when an SLA task event occurs (e.g., SLA breach, SLA warning).

Configuration Parameters

This trigger has no input configuration parameters. It automatically activates for SLA task events.

Output Fields

FieldTypeDescription
task_sla_recordreferenceReference to task_sla record
sla_flow_inputsobjectSLA-specific input data

sla_flow_inputs Structure

{
duration: string, // SLA duration
relative_duration_works_on: string, // Schedule for duration calculation
is_repair: boolean, // Whether this is a repair SLA
duration_type: string, // Type of duration calculation
name: string // SLA definition name
}

trigger.application.serviceCatalog

Activates when a Service Catalog request item workflow needs to be processed.

Configuration Parameters

ParameterTypeDefaultRequiredDescription
run_flow_in'any' | 'background' | 'foreground''any'NoExecution context for the flow

Output Fields

FieldTypeDescription
request_itemreferenceReference to sc_req_item record (catalog request item)
table_namestringTable name, always "sc_req_item"
run_start_timedatetimeWhen the trigger started execution
run_start_date_timedatetimeAlternative field for run start time

trigger.application.knowledgeManagement

Activates when knowledge management events occur (e.g., knowledge article published, retired).

Configuration Parameters

This trigger has no input configuration parameters. It automatically activates for knowledge management events.

Output Fields

FieldTypeDescription
knowledgereferenceReference to kb_knowledge record
table_namestringTable name (default: 'kb_knowledge')
run_start_timeglide_date_timeFlow execution start time
run_start_date_timeglide_date_timeFlow execution start date/time

trigger.application.remoteTableQuery

Activates when a remote table is queried from an external system.

⚠️ Synchronous execution: The calling system waits for flow completion. Keep processing fast (target <2 seconds response time). Cannot run in background.

Configuration Parameters

ParameterTypeDefaultRequiredDescription
u_tablestring-NoRemote table name (from sys_script_vtable)

Output Fields

FieldTypeDescription
table_namestringRemote table name
query_parametersobjectName-value pairs of query parameters
query_idstringUnique identifier for this query

For when-to-use guidance, best practices, and end-to-end trigger examples, see the Trigger Guide.