Overview: Simple tasks in workflow
- Assign tasks to Change Requests
- Rolling back tasks.
Tasks in ServiceNow workflow
The ServiceNow Workflow Editor provides three Activities to assign and manage Tasks using the Create Task Activity.
The tasks created from within a workflow typically appear inside a Related List of the Current record.
The Workflow Engine creates the tasks and then waits for a Complete or Incomplete state to transition forward.
The interaction between the state change of tasks and the Workflow Engine is through the update of the Current record.
The update event will invoke the Glide Script Engine and fire the update event into the Workflow.
1. In the Workflow Editor click Open.
2. Locate and select the K14 Change Task Example workflow.
Your workflow should look like this:
You’ll notice this is very similar to out last Workflow. So the test steps will be familiar.
3. Select Gear Menu > Check Out.
4. Select Gear Menu > Properties.
5. Expand the Tasks Category in the Activities Tree.
6. Drag the Create Task Activity onto the transition between Log Approval One and Approval Two – Create Task Example.
Fill out the form as shown:
Name: Create a Change Task
Task Type: Change Task [change_task]
Assigned to: K14Task OneUser
Short Description: Task assigned to K14 User One
Instructions: Enjoy your conference!
Notice the Wait for Completion checkbox. When checked, this will cause the Workflow to wait for the task to be in a State of Complete or Incomplete prior to transitioning to the next Activity.
7. Click the Submit button.
Your screen should look like this:
QUESTION: Find the Create Task in the Rollback Path. What will be the state of the Create Task in the Workflow Context Activity History Related List if the Approval Two Activity is Rejected?
Tasks have rolled back states, just like the Approvals did in the previous lab. If a Task is in the path of a rollback, its State is set to Pending. If a task is the target of a Rollback To transition, the task state is set to Open.
8. Return to the main tab of the ServiceNow instance.
9. Change > Create New.
10. Set the Priority: 3 –Moderate.
11. Right click in the form header and Select Save.
12. Scroll to the Related Lists.
13. Select the Approver Tab.
14. Right Click > K14-Approver One the Requested Approval to approve.
15. Select the Change Tasks Related List.
Notice now the new task has been added to the Change Request.
16. Right Click > Close Task.
17. Select the Approvers Related List.
18. QUESTION: We are going to Reject the Requested Approval. What will be the new State of K14-Approval One? Approval Two?
19. Right Click > Reject the K14-Approver Two Requested Approval.
20. Reselect the Change Tasks Related List.
Note the rolled back state of the Change Task is set to Pending.21. Select Show Workflow from the Related Links list to view the workflow.
22. Close the browser tab of the Workflow Context view.
23. Reselect the Approvers Related List.
24. Right Click > Approve the K14-Approver One Requested Approval.
25. Reselect the Change Tasks Related List.
26. Right Click > Close Task.
27. Reselect the Approvers Related List.
28. Right Click > Approve the K14-Approver Two Requested Approval.
29. Select the Show Workflow link for the Related Links list.
The workflow context is displayed.
The Create Task Activity allows the designer to decide if the workflow should wait for the task to complete before transitioning to the next Activity. If the designer selects Wait for Complete, the Workflow inserts the task into the database and wait for an update from that record. When the user changes the state of the task, the Workflow Engine is notified of the update event and the Activity will finish and transition to the next Activity.
Completed tasks have a State change when they are in a rollback path.
- The state of Tasks in a rollback path will set to Pending.
- Tasks that are the destination of a Rollback To Activity will be set to Open.