{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":15246,"path":"field-service-management/work-order-management/state-flow-example.md","title":"State flow example","bundle":null,"doc_type":null,"release":"australia","body":"\n# State flow example\n\nYour business processes might require work order tasks to be accepted automatically when dispatched to an agent.\n\n## Before you begin\n\nRole required: admin\n\n## About this task\n\nCreate a new state flow record that automates the transition from Pending Dispatch to Accepted and bypasses the Assigned state in which agents can reject tasks. This prevents the system from running the manual script associated with UI actions. The automatic script performs the jobs that the manual script performed, such as updating the date and time the task was dispatched, or to do additional work such as sending a notification.\n\n## Procedure\n\n1.  Navigate to **All** &gt; **Field Service** &gt; **State Flows** &gt; **Work Task Flows**.\n\n2.  Open the **Assigned** record that defines a task transition from a starting state of **Pending Dispatch** to an ending state of **Assigned**.\n\n    This is an automatic state change that occurs when an agent's name is added to the Assigned to field and the task is updated.\n\n3.  Change the name of the state flow.\n\n    In this example, change the name to **Skip Agent Acceptance**.\n\n4.  Change the value in the **Ending state** field to **Accepted**.\n\n    This transition allows you to bypass the **Accept** state flow record that enables agents to reject tasks.\n\n5.  Set up the condition criteria in the following fields:\n\n    -   **Automatic condition string**: This condition ensures that the current state is at **Pending Dispatch** and the value in the **Assigned to** field changes. For example, `current.state == 10 && current.assigned_to.changes()`.\n    -   **Automatic condition**: The condition **\\[Assigned to\\] \\[is not empty\\]**ensures that all dispatched tasks are accepted automatically.\n    -   **Automatic script**: The automatic script sets the time the task was dispatched. For example, use method: `current.dispatched_on = gs.nowDateTime();`.\n    **Note:** The previous two condition statements have an **\\[and\\]** relationship. In this example, the business rule runs when a task in a state of **Pending Dispatch** is assigned to any agent.\n\n6.  Copy the record using the **Insert and Stay** command.\n\n    This action increments the record number and clears the **Business rule** field. The system automatically creates a new business rule, using the name of the new state flow record. The Skip Agent Acceptance business rule moves the task from **Pending Dispatch** to **Accepted** automatically when a dispatcher enters a user name in the **Assigned to** field. Note that any changes you make to this state flow record in the future are executed by this business rule.\n\n7.  Ensure that the **Active** check box is selected.\n\n8.  In the Work Task Flows list, locate the **Accept** state flow record and change the **Active** status to **false**.\n\n    This action deactivates the transition that allows agents to accept tasks and moves the state flow directly from **Pending Dispatch** to **Accepted**.\n\n\n"}}