{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":15092,"path":"field-service-management/work-order-management/configure-state-flow.md","title":"Configure state flows for work orders and work order tasks","bundle":null,"doc_type":null,"release":"australia","body":"\n# Configure state flows for work orders and work order tasks\n\nState flows control the sequence in which work orders and work order tasks transition from one state to another. You can customize state flows to control the sequence in which records transition between states in Service Management applications.\n\n## About this task\n\nDefine all of the possible state transitions that represent the life cycle of a work order. However, customizing state flows requires scripting knowledge.\n\n## Before you begin\n\nRole required: admin\n\nBefore 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.\n\n**Note:** The **State** field on the record is always read-only.\n\n## Procedure\n\n1.  Navigate to **All** &gt; **Configuration** &gt; **Field Service** then choose one of the following:\n\n    -   **Work Order Flows**\n    -   **Work Task Flows**\n    **Important:** Make sure that you deactivate the original record so the system cannot use it.\n\n2.  Open the record for the transition you want to customize.\n\n3.  Right-click the form header and select **Insert and Stay**.\n\n    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.\n\n4.  Ensure that the **Active** check box is selected.\n\n5.  In the appropriate section, configure a transition method:\n\n    -   **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\n    -   **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\n6.  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.\n\n7.  Complete the **Field Controls** section to control how specific fields appear when a record changes states.\n\n    **Note:** The system enforces the field controls with the same client script you created to filter the choice list for the **State** field.\n\n8.  Click **Update**.\n\n9.  Reopen the source record you copied and clear the **Active** check box.\n\n    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.\n\n10. Open the copied state flow record you want to customize.\n\n11. On the form, fill in the fields.\n\n<table id=\"table_sbb_kzd_dbc\"><thead><tr><th>\n\nField\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nNumber\n\n</td><td>\n\nRecord number automatically generated by the ServiceNow® system.\n\n</td></tr><tr><td>\n\n\\[Required\\] Table\n\n</td><td>\n\nTable on which the state flow record runs. The possible tables are: -   Work Order Task \\[wm\\_task\\]\n-   Work Order \\[wm\\_order\\]\n\n\n</td></tr><tr><td>\n\nStarting state\n\n</td><td>\n\nName of the state at the beginning of the transition.\n\n</td></tr><tr><td>\n\nEnding state\n\n</td><td>\n\nName of the state at the end of the transition.\n\n</td></tr><tr><td>\n\nClient script\n\n</td><td>\n\nClient 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.\n\n</td></tr><tr><td>\n\nEvent\n\n</td><td>\n\nName of an existing event to trigger when this transition occurs.\n\n</td></tr><tr><td>\n\nName\n\n</td><td>\n\n\\[Required\\] State name as it appears in the choice list.\n\n</td></tr><tr><td>\n\nRoles\n\n</td><td>\n\nRoles required to configure the **State** field that uses the custom transition.\n\n</td></tr><tr><td>\n\nActive\n\n</td><td>\n\nSwitch for enabling or disabling this state flow record.\n\n</td></tr><tr><td>\n\nClass\n\n</td><td>\n\nAvailable state flow classes: -   **State Flow:**Records created for state flows in all task-based tables except those in Field Service Management.\n-   **Work Order Flow:** Records created for state flows in the Work Order \\[wm\\_order\\] table.\n-   **Work Task Flow:** Records created for state flows in the Work Order Task \\[wm\\_task\\] table.\n 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.\n\n</td></tr><tr><td>\n\nOverride\n\n</td><td>\n\nDefault starting value for the **State** field on all new records for the table named in the state flow record.\n\n</td></tr><tr><td>\n\nWork notes\n\n</td><td>\n\nComments about this state flow transition.\n\n</td></tr><tr><td>\n\nComment\n\n</td><td>\n\nDetails about the customized record.\n\n</td></tr><tr><td colspan=\"2\">\n\n**Manual** \\(Runs scripts from a UI action that requires the user to click a button or related link.\\)\n\n</td></tr><tr><td>\n\nManual condition string\n\n</td><td>\n\nConditions 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.\n\n</td></tr><tr><td>\n\nManual condition\n\n</td><td>\n\nCondition 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.\n\n</td></tr><tr><td>\n\nManual script\n\n</td><td>\n\nScript 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.\n\n</td></tr><tr><td>\n\nUI action\n\n</td><td>\n\n\\[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.\n\n</td></tr><tr><td colspan=\"2\">\n\n**Automatic** \\(Runs a business rule automatically when a task record is changed and updated.\\)\n\n</td></tr><tr><td>\n\nAutomatic condition string\n\n</td><td>\n\nConditions 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.\n\n</td></tr><tr><td>\n\nAutomatic condition\n\n</td><td>\n\nConditions 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.\n\n</td></tr><tr><td>\n\nAutomatic script\n\n</td><td>\n\nScript 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.\n\n</td></tr><tr><td>\n\nBusiness rule\n\n</td><td>\n\nName 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.\n\n</td></tr><tr><td colspan=\"2\">\n\n**Field Controls** \\(Determines field properties when a record transitions between states.\\)\n\n</td></tr><tr><td>\n\nMandatory fields\n\n</td><td>\n\nFields required when this transition occurs or when the **Ending state** is the current state of a work order or work order task.\n\n</td></tr><tr><td>\n\nRead only fields\n\n</td><td>\n\nFields 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.\n\n</td></tr><tr><td>\n\nVisible fields\n\n</td><td>\n\nFields made visible when this transition occurs or when the **Ending state** is the current state of a work order or work order task.\n\n</td></tr><tr><td>\n\nNot mandatory\n\n</td><td>\n\nFields set as optional when this transition occurs or when the **Ending state** is the current state of a work order or work order task.\n\n</td></tr><tr><td>\n\nNot read only\n\n</td><td>\n\nFields 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.\n\n</td></tr><tr><td>\n\nNot visible\n\n</td><td>\n\nFields hidden when this transition occurs or when the **Ending state** is the current state of a work order or work order task.\n\n</td></tr></tbody>\n</table>\n"}}