Close
Thank you for your feedback.

Customize a state flow

Customize a state flow

You can customize state flows to control the sequence in which records transition between states in SM applications.

About this task

Customizing state flows requires scripting knowledge.

Procedure

  1. Before customizing a state flow, make a copy of the state flow record for the transition you want to change and do all your customizations in the copied record.

    This allows the system to update the default state flow record automatically during an upgrade and enables you to revert to the default record if necessary.

  2. Make sure to deactivate the original record so the system cannot use it.

  3. Navigate to the class of state flows you want to customize.

    • State Flows > Work Order Flows
    • State Flows > Work Task Flows

  4. Open the record for the transition you want to customize.

  5. Right-click the form header and select Insert and Stay.

    The system clears any values from the Business rule and UI action fields. A notification appears at the top of the form describing the action taken.
  6. Ensure that the Active check box is selected.

  7. In the appropriate section, configure a transition method:

    • Manual: Click Create UI Action to create a button on the form that enables users to execute the transition manually. The system uses the value in the Name field as the label for the UI action. The UI action executes the script in the Manual Script field when the conditions are true
    • Automatic: Click Create Business Rule to create the business rule. The business rule executes the script in the Automatic Script field when the conditions are true

  8. Click Create Client Script to create the script that limits the values available a record's State field choice list to valid states for that transition

  9. Complete the Field Controls section to control how specific fields appear when a record changes states. The system enforces the field controls with the same client script you created to filter the choice list for the State field.

  10. Click Update

  11. Reopen the source record you copied and clear the Active check box

    Deactivating the original record allows the system to upgrade it normally when the instance is upgraded and prevents the system from using the record rather than your custom state flow.
  12. Open the copied state flow record you want to customize.

  13. Fill in the fields, as needed.

    Figure 1. Work task flow
    Work Task Flow

    Table 1. Work task flow
    FieldDescription
    Number Record number automatically generated by the ServiceNow system.
    [Required] Table Table on which the state flow record runs. The possible tables are:
    • Work Order Task [wm_task]
    • Work Order [wm_order]
    Starting state Name of the state at the beginning of the transition.
    Ending state Name of the state at the end of the transition.
    Client script Client script to run for this transition. The client script controls the available starting and ending states you can select by limiting the contents of the State choice list to valid states.
    Event Name of an existing event to trigger when this transition occurs.
    Name [Required] State name as it appears in the choice list.
    Roles Roles required to configure the State field that uses the custom transition.
    Active Switch for enabling or disabling this state flow record.
    Class Available state flow classes:
    • State Flow: Records created for state flows in all task-based tables except those in Field Service Management.
    • Work Order Flow: Records created for state flows in the Work Order [wm_order] table.
    • Work Task Flow: Records created for state flows in the Work Order Task [wm_task] table.

    This field is required for users with the admin role. Users with the wm_admin role can only create state flow records in the Work Order Flow and Work Task Flow classes and cannot edit this field in the record.

    Override Default starting value for the State field on all new records for the table named in the state flow record.
    Work notes Comments about this state flow transition.
    Comment Details about the customized record.
    Manual (Runs scripts from a UI action that requires the user to click a button or related link.)
    Manual condition string Conditions for enabling a UI action that cannot be defined with the condition builder . For example, you can use this string to define UI actions for mobile devices. This condition has an [and] relationship with the condition in the Manual condition field.
    Manual condition Condition builder for enabling a UI action that can be defined for fields in the target table. This condition has an [and] relationship with 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] Names the UI action to enable for this transition. By default, this UI action creates a button on the task form. Click Create UI Action to create the button. The button inherits the name of the state flow record in which it was created.
    Automatic (Runs a business rule automatically when a task record is changed and updated.)
    Automatic condition string Conditions for running the business rule that cannot be defined with the condition builder. For example, use this condition to evaluate if the proposed transition is a valid flow. This condition has an [and] relationship with the condition in the Automatic condition field.
    Automatic condition Conditions for running the business rule that can be defined for fields in the target table. This condition has an [and] relationship with the condition in the Automatic condition string field.
    Automatic script Script that performs additional work when the condition is true. This script can do tasks such as update the date and time the transition occurred or notify someone of a milestone.
    Business rule Name of the business rule created for this transition. The business rule has a condition to ensure the validity of the flow. If that condition is true, the business rule performs the transition requested, using the starting and ending states from the Work Order Flow or Work Task Flow form.
    Field Controls (Determines field properties when a record transitions between states.)
    Mandatory fields Fields required when this transition occurs or when the Ending state is the current state of a work order or work order task.
    Read only fields Fields set as read-only when this transition occurs or when the Ending state is the current state of a work order or work order task.
    Visible fields Fields made visible when this transition occurs or when the Ending state is the current state of a work order or work order task.
    Not mandatory Fields set as optional when this transition occurs or when the Ending state is the current state of a work order or work order task.
    Not read only Fields that can be edited when this transition occurs or when the Ending state is the current state of a work order or work order task.
    Not visible Fields hidden when this transition occurs or when the Ending state is the current state of a work order or work order task.

Products > Service Management > Field Service Management; Versions > Helsinki