State Flows: PDF Generated At: Tue, 21 Oct 2014 13:04:41 PST
State Flows: PDF Generated At: Tue, 21 Oct 2014 13:04:41 PST
State Flows: PDF Generated At: Tue, 21 Oct 2014 13:04:41 PST
PDF generated using the open source mwlib toolkit. See http://code.pediapress.com/ for more information.
PDF generated at: Tue, 21 Oct 2014 13:04:41 PST
1
Introduction
State Flows
Overview
State flows enable an administrator to customize transitions from one state to another in tables derived from the Task
[task] table and configure the system to perform work during transitions to specific states. An example of a state
transition is when the State field in an incident changes from Active to Awaiting User Info. An administrator might
want to trigger an event during this transition or make a specific field mandatory when the incident reaches the end
state.
State transitions in the Work Management application were reimplemented to use state flows. For information about
customizing Work Management state flows, see State Flow Customization.
The state flows feature is available starting with the Eureka release.
script in a state flow record and create a condition to trigger processing for any state change that requires it. An
example of this in work management is the Roll Up Changes business rule on the Work Order Task [wm_task] table.
This business rule rolls up state changes that occur in tasks to the parent work order.
Roles
Users with the admin role can create, edit, and delete state flow records.
• State Flows: Shows all state flows for task-based tables. Work order and work order task state flow
records are not displayed unless Work Management is activated.
• Work Order Flows: Shows all state flows defined for work orders. This module is available when
Work Management is activated.
• Work Task Flows: Shows all state flows defined for work order tasks. This module is available when
Work Management is activated.
• Admin
• Rebuild State Flows: Updates links to the states in a state flow record to repair damaged state
flows.
Tables
State flows add the following table.
Table Description
State Flow [sf_state_flow] Contains state flow definitions. This table contains all state flow definitions, including those for work orders and
work order tasks.
Work Order Flow Contains state flow definitions for work orders. This table is installed when Work Management is activated.
[sf_work_order]
Work Task Flow Contains state flow definitions for work order tasks. This table is installed when Work Management is activated.
[sf_work_task]
Script Includes
State flows add the following script includes.
Name Description
StateFlow Implements state flows and supports creation of state flow elements, such as business rules, UI actions, dictionary overrides, and
client scripts.
Business Rules
State flows add the following business rules.
Assert Field Uniqueness in State Flow Ensures that business rules and UI actions are not accidentally copied to new state flows.
State Flow [sf_state_flow]
Check Client Script State Flow Adds a client script to new records.
[sf_state_flow]
Check Event Rule State Flow Adds or deletes event rules, as the event field is updated.
[sf_state_flow]
Check Work Notes Rule State Flow Adds or deletes work note rules, as the work notes for a state flow are updated.
[sf_state_flow]
Create Business Rule State Flow Automatically creates a business rule when automatic conditions or script are present.
[sf_state_flow]
Installed with State Flows 4
Create script for Field controls State Flow Create scripts for field controls, when they are in use
[sf_state_flow]
Create UI Action State Flow Automatically creates a UI action when manual conditions or script are filled in.
[sf_state_flow]
Delete Related Elements State Flow When state flows are deleted, delete all related client scripts, business rules, UI actions
[sf_state_flow] and overrides.
Remove script for Field State Flow If all field controls are disabled, see if any of the client scripts should be removed.
controls [sf_state_flow]
State Change State Flow Get the correct state choice value when the state is changed.
[sf_state_flow]
Update dependent records State Flow When a state flow is made active or inactive, ensure the business rule and UI actions are
[sf_state_flow] made active or inactive as well.
5
Using
Field Description
Table [Required] Table on which the state flow record runs. Only tables that extend the Task [task] table are available in the list.
Starting state Name of the state at the beginning of the transition. The selections in this field are filtered by the possible states for the table
selected. For more information, see Start and End States.
Ending state Name of the state at the end of the transition. The selections in this field are filtered by the possible states for the table selected.
Client script Client script to run for this transition. The client script controls the available states you can select by limiting the contents of the
State choice list to valid states. This client script also controls specific field behavior configured for state changes in the Field
Controls section of the form.
Event Name of an existing event to trigger when this transition occurs. See Triggering Events on State Changes for more information.
Name [Required] Name of this record. Make sure the name is descriptive of the state transition or the processing that the record is
performing. This name does not have to be unique.
Class [Required] Defines the state flow class for this record. The system selects the appropriate class from these options:
• State Flow: Records created for state flows in all task-based tables except those in work management.
• Work Order Flow: Records created for state flows in the Work Order [wm_order] table. This class is available when work
management is activated.
• Work Task Flow: Records created for state flows in the Work Order Task [wm_task] table. This class is available when work
management is activated.
Dictionary Sets the starting value for the State field on all new records for the table named in the state flow record. See Dictionary Overrides
override for configuration procedures.
Work notes Noteworthy comments about this state flow transition. For details about how these notes are used, see Work Notes.
Manual (Runs scripts from a UI action that require the user to click a button or related link.)
Manual Conditions for enabling a UI action that cannot be defined with the condition builder. For example, you can use this string to
condition string define UI actions for mobile devices. This condition has an [and] relationship with the condition in the Manual condition field.
Manual Conditions for enabling a UI action that can be defined for fields in the target table. This condition has an [and] relationship with
condition the condition in the Manual condition string field.
Manual script Script that defines what the UI action does when the conditions are true. This script runs when the user clicks a button or a related
link.
UI action [Read Only] Name of the button that the system creates to enable this transition. The system creates the label using the same name
as the state flow record that created it.
Automatic (Runs a business rule automatically when a task record is changed and updated.)
Automatic Conditions for running the business rule that cannot be defined with the condition builder, such as evaluating if the proposed
condition string transition is a valid flow. This condition has an [and] relationship with the condition in the Automatic condition field.
Automatic Conditions for running the business rule that can be defined for fields in the target table. This condition has an [and] relationship
condition with the condition in the Automatic condition string field.
Automatic Script that performs additional work when the condition is true. This script can do tasks such as update the date and time the
script transition occurred or notify someone using email when a specific state change occurs. Automatic state transitions occur when
changes are made to the task record.
Business rule Name of the business rule created for this transition. Two conditions must be satisfied before this business rule can run. The task
must be on a specific starting state, and the Automatic condition must be true. If both of these conditions are satisfied, the
business rule performs the transition requested, using the starting and ending states from the State Flow form.
Field Controls (Determines field properties when a record transitions between states or reaches a specific end state.)
Using State Flows 7
Mandatory Makes the selected fields required when this transition occurs, or when the end state is the current state.
fields
Read only Prevents the selected fields from being edited when this transition occurs, or when the end state is the current state.
fields
Visible fields Displays the selected fields when this transition occurs, or when the end state is the current state.
Not mandatory Makes the selected fields optional when this transition occurs, or when the end state is the current state.
Not read only Makes the selected fields editable when this transition occurs, or when the end state is the current state.
Not visible Hides the selected fields when this transition occurs, or when the end state is the current state.
Dictionary Overrides
A dictionary override in a state flow defines the starting state for all new records in a specific table. You set an
override in tables that extend a base table only, so that your customizations are applied only to the extended table.
1. In a state flow record, select an Ending state.
This is the override value which becomes the starting state for all new records in the table named.
2. Click Create Default Value.
The system populates the Dictionary override field with a value of state, which is the field in the task table
affected by the override. The Dictionary override field is read-only. After the override is created, the system
hides the Create Default Value button on all subsequent state flow forms for that table.
Work Notes
Work notes are an important part of the state flow process and are used to communicate information about state
transitions. The state flow adds these work notes to the Work notes field of any task making this transition.
These rules apply to state flow work notes:
• For a state flow with no Starting state, the work note is added every time the task transitions to the Ending state.
• For a state flow with a Starting state and an Ending state, the work note is added only when the task transitions
from that starting state to that ending state.
• If two state flows with work notes have the same Ending state, but only one has a Starting state, the system
adds the work notes from the state flow with the starting state. This better matches the state flow work note to the
more important transition between specific starting and ending states.
Field Controls
You can define controls for individual fields that are enforced when a record transitions between states. Settings in
the Field Controls section of the State Flow form enable you to apply field controls when the system detects a
specified state transition or when the end state is the current state when the form is opened. The control is applied
only to existing fields on the form. State flows cannot add fields to the form.
For example, you might want the Problem field to be visible when an incident moves to the Awaiting Problem
state. If the incident state changes to Awaiting User Info, you hide the Problem field and make the Caller field
mandatory.
The best practice when creating field controls is to configure state flow records with an ending state only and to
create the correct behavior for every ending state you want to control. This ensures that the field controls are set
properly when the user selects a new state, and also when the user returns a record's State field to the original state.
Only specify a full state transition, with both a starting and ending state, when you want a particular behavior for that
precise state transition.
Using State Flows 8
Note: State flows use client scripts to enforce field controls. It is possible that your settings can be changed by existing UI policies,
which execute after client scripts.
ServiceNow creates the following objects as needed to enforce field properties in state flows:
Business rule State Flow Notes for <table Enforces mandatory fields for the table on which that field behavior is defined.
name>
Client script (onLoad) <table name> state flow Sets possible states and initial mandatory, read-only, and visible properties when a record
is loaded.
Client script <table name> change state flow Sets updated mandatory, read-only, and visible properties when a record is changed.
(onChange)
Business rule that processes events triggered by a state flow All state flows for the table specified that have events configured are deleted.
Client script (onLoad) All state flows for the table are deleted.
Client script (onChange) All state flows with field controls are deleted.
Work notes business rule All state flows with field controls or work notes are deleted
Article Sources and Contributors 10