Vous êtes sur la page 1sur 48

Workflow Objectives

In this module you will learn to:

 Open and use the Workflow editor

 Create and edit workflows

 Add activities to workflow

 Configure activities

 Check out and publish workflows

 Use workflow contexts to debug workflow

What is a Workflow?

A workflow is a sequence of activities for automating processes in applications. This is the


baseline Team Development Code Review workflow:
Activities are workflow blocks which perform different tasks such as obtaining approvals,
sending email, running scripts, testing conditions, and setting field values on records.

All workflows star t with a Begin activity and end execution with an End activity. When an
activity completes, the activity exits through the appropriate node and the transition is followed
to the next activity.

Workflow are launched a number of different ways including:


 Triggered by field values on a record

 UI Action

 Server-side scripts

When to Use Workflows

Use workflows to automate multi-step processes such as:

 Approvals

 SLAs

 Task creation

 Event generation

 Email notifications

Many of these activities such as task creation, event generation, and email notifications can be
accomplished using other strategies. The decision to use a workflow or not depends on whether
you are automating a process or if the activity is a discrete action. For example, if an email needs
to be sent when a new record is inserted into the database, that is a discrete action which does not
require workflow. If the email is sent when a request is approved or rejected, this is a multi-step
process which can be automated with workflow.

Workflow Editor

The Workflow editor is the interface for visually defining processes. Use the Workflow editor to
create and modify workflows by adding, arranging, deleting, and connecting activities.

The procedure for adding files to an application in Studio is the same regardless of file type:
1. Select the Create Application File button.

2. Choose the new file type, in this case, Workflow.

3. The Workflow editor opens in a new window.

4. Create the workflow.

The Workflow editor Welcome tab displays helpful links to Workflow Editor Video Tutorials,
community conversations, the Workflow Dashboard, and Knowledge Articles.

NOTE: When launched from the Application Navigator in the main ServiceNow browser
window (Workflow > Workflow Editor), the Workflow editor opens in a new tab instead of a
new window.

The Workflow editor is a drag-and-drop development environment.

 Canvas tabs: Create new or access existing workflows. Multiple workflows can be open.

 Title bar: Displays workflow name, status and controls for configuring, testing and
validating.

 Workflow menu: Menu to configure the current workflow.

 Workflow properties: Opens the current workflow’s properties form.


 Start: Runs the workflow. Only available for tables in the Global scope. To test
workflows in a private scope, insert a new record into the table you are testing meeting
the condition of the workflow.

 Validate: Detects potential problems that can prevent publication or cause the workflow
to fail.

 Help: Opens workflow documentation.

 Canvas: Working surface for creating new or edit existing workflows.

 Palette: Workflow and Core tabs are available. Additional tabs/features if Orchestration
is active.

 Workflows: Displays a list of existing workflows. Select the + sign to create a new
workflow.

 Core: Displays a list of available workflow activities.

Opening Existing Workflow

To open a workflow for editing, select the Workflows tab in the Palette. Click a workflow to
open it in its own Workflow editor tab.

The Workflow editor takes its scope from the window or tab which launched the Workflow
editor. The Workflow editor scope cannot be changed. Any workflow can be opened but only in-
scope workflow are editable. Activity configuration fields are read-only for out-of-scope
workflows.

Checking Out Workflow

To prevent developers from making changes to a workflow which will impact other users,
workflows need to be checked out before they can be edited. When a workflow is checked out,
changes are applied to the workflow only for the user who checked it out. When development is
complete, workflows must be published to be active in the environment.

To check out a workflow, open the Workflow actions menu ( ) and select
the Checkout menu item.
Creating a Workflow

To create a workflow in Studio, click the Create Application File button, select Workflow, then
click the Create button.

To create a workflow in the Workflow editor, click the New button ( ).

The Workflow editor takes its scope from the window which launches it. As a result, new
workflow have the same scope as the window which launched the Workflow editor.
Configure the workflow:

 Name: A unique name for the Workflow.

 Table: The table the Workflow executes against.

 If condition matches: What to do when the condition matches. None means the
Workflow needs to be launched through a UI Action, script, or manually.

 Description: Describe the workflow to document what it does and how.

 Condition: Under what conditions should the Workflow run?

New workflows are automatically checked out to the user who created them. The workflow
template contains Begin and End activities.
Adding Activities to a Workflow

Technique 1

Switch to the Core tab in the Palette. Click, hold, and drag an activity onto the canvas. Hover the
activity over a transition. When the transition turns blue, drop the activity.
After dropping the activity, the activity configuration screen opens. Configure the activity then
click the Submitbutton.

Technique 2

Switch to the Core tab in the Palette. Double-click an activity to add the activity to the canvas.
The configuration screen opens. After configuring the activity click the Submit button. Although
the new activity appears on the canvas it is not part of the workflow because no transitions
connect it to the other activities. Activities created this way cannot be dragged onto a transition
to connect it into the workflow; transitions must be added manually.

Adding and Deleting Transitions

To delete a transition, click on the transition to select it. Selected transitions are blue. Press
the <delete> button on the keyboard.

Selected transition:

Not selected transition:


No transition:

To add a transition, click, hold, and drag from an activity node to another activity. When the
activity turns blue, release the mouse.

NOTE: Workflows do not need to be saved. All changes are written directly to the database.
Configuring Workflow Activities

Every workflow activity has a different set of configuration fields. The configuration fields are
dependent upon what an activity does. For example, the Approval - User activity needs to know
the approver(s).

The Notification activity which sends an email needs to know the recipient(s), subject, and
message.
The activity configuration fields are documented on the ServiceNow docs site. Click the Help

button ( ) in the Palette to find information about activity configuration.


When the docs.servicenow.com site opens, select the appropriate ServiceNow version.

Validating Workflows

Workflow validation is the first step in ensuring a workflow is error-free. It cannot test whether a
workflow does what you want it to. Validation prevents workflows with critical flaws from
executing and resulting in an unstable or incomplete state.

To validate a workflow, click the Validate button ( ).

Validation checks for issues like:

 Activities with missing transitions

 Multiple or missing End activity

 Invalid table references

The Workflow Validation Report lists the validation tests and results. There are message levels:
Info, Warn, and Critical. Critical and Warn messages must be corrected before a workflow can be
published.
Exercise: Create the NeedIt Approval Workflow

In this exercise you will create a workflow for the NeedIt application. The workflow will have
three activities:

 Request Manager Approval

 Set State Value on Reject

 Set State Value on Approval

Preparation

1. Open a NeedIt record to examine the State field choice list values.

a. In the main ServiceNow browser window (not Studio) use the Application Navigator to
open NeedIt > Open.

b. Open a record from the list of NeedIt records.

c. Examine the State field. What is the current value?

d. Click the State field choice list and examine the choices.

Create the NeedIt Approval Workflow

1. If the NeedIt application is not open in Studio from the last exercise, open it now.

a. In the main ServiceNow browser window use the Application Navigator to open System
Applications > Studio.

b. In the Load Application dialog, click the NeedIt application.

2. Create a workflow.

a. In Studio, click the Create Application File button.

b. In the Filter… field enter the text Workflow OR select Workflow from the categories in
the left hand pane.

c. Select Workflow in the middle pane as the file type then click the Create button.

2. Configure the workflow:

Name: NeedIt Approval

Table: NeedIt [x_<your_company_code>_needit_needit]


Description: Request approval from Requested for’s manager and set state value on
reject or approve.

If condition matches: Run the workflow

Condition: [State] [is] [Awaiting Approval]

1. Click the Submit button.

2. Examine the canvas header. Notice the new workflow is automatically checked out to
you.

Add an Approval - User Activity

1. Switch to the Core tab in the Palette.

2. Expand the Approvals category.

3. Locate the Approval - User activity.

4. Click, hold, and drag the Approval - User activity into the canvas. Hover the activity
over the transition between the Begin and End activities. When the transition turns blue,
drop the activity.

5. Configure the workflow:


Name: Request Manager Approval

6. Add the Requested for’s manager as the approver.

a. Scroll to the Approvers section.

b. Click the lock button ( ) for the Users field.

c. Click the Select fields button ( ).

d. Click the Expand button ( ) for the Requested for field in the Select fields for the list
window.

e. Click the Manager field for the Requested for.

f. Click the lock button to collapse the Users field.


2. Set the Wait for field value to Anyone to Approve. There is only one approver so
Everyone to approve or First response from anyone would also work.

3. Click the Submit button.

4. Examine the Workflow. Verify there is a transition from the Begin activity to the
Approval - User and another from the Approval - User activity to the End activity. There
should be arrowheads at the end of each transition. The Approval - User activity should
connect to the End activity through the Approved node.

QUESTION: What does the syntax u_requested_for.manager mean in the Users field? If you
aren’t sure, scroll to the Answers section at the bottom of this page.

Add a Set Values Activity to the Approved Transition

1. Switch to the Core tab in the Palette.

2. Expand the Utilities category.

3. Locate the Set Values activity.


4. Click, hold, and drag the Set Values activity into the canvas. Hover the activity over the
transition between the Approval - User activity Approved node and the End activity.
When the transition turns blue, drop the Set Values activity.

5. Configure the workflow: Name: Set State to Approved

6. Set the State field value.

a. Scroll to the Values section.

b. Set the State field value to Approved.

2. Click the Submit button.

3. Examine the Workflow. Verify there is a transition from the Approval - User activity
Approved node and the Set Values activity. There should also be a transition from the Set
Values activity to the End activity. Your workflow layout on the canvas might be different
than the layout in the screenshot. As long as the transitions correctly connect the
activities, the layout doesn’t matter.

Add a Set Values Activity for Rejected

1. Switch to the Core tab in the Palette.

2. If collapsed, expand the Utilities category.

3. Locate the Set Values activity.

4. Since there is no Rejected transition to drag the Set Values activity to, double-click the
Set Values activity.

5. Configure the workflow: Name: Set State to Closed Complete

6. Set the State field value.

a. Scroll to the Values section.

b. Set the State field value to Closed Complete.

2. Click the Submit button.

3. Locate the new Set Values activity on the canvas. It is most likely in the upper left side of
the canvas. Drag it to a new location on the canvas so it doesn’t overlap with other
activities.

4. Add transitions to the new Set Values activity to connect it to the workflow.

a. Click on the Rejected node ( ) of the Approval - User activity and drag to the new Set
Values activity. When the Set Values activity turns blue, release the mouse.
b. Click on the Always node of the Set Values activity and drag to the End activity. When
the End activity turns blue, release the mouse.

2. Examine the Workflow. Verify the transitions are correct. Your workflow layout on the
canvas might be different from the layout in the screenshot. As long as the transitions
correctly connect the activities, the layout doesn’t matter.

You are probably eager to test the workflow. You’ll get to do that in the next Exercise after you
learn about contexts and debugging.

QUESTION: Why were there no instructions to save the workflow? If you aren’t sure, scroll to
the Answers section at the bottom of this page.

Validate the Workflow

1. To validate the workflow, click the Validate button ( ) in the canvas header.
2. Examine the Workflow Validation Report. There should be no Warn or Critical level
messages. If you have Warn or Critical messages, use the report to determine the issue.
Make any necessary corrections.

Answers

Question: What does the syntax u_requested_for.manager mean in the Users field?

Answer: This syntax is known as dot-walking. u_requested_for (Requested for) is a reference


field on the NeedIt. The Requested for field value references a record on another table, Users.
The dot-walking syntax tells ServiceNow to locate the Requested for record on the User table
and use the value from the Manager field. Dot-walking allows ServiceNow to dynamically
determine the Requested for’s manager.

Question: Why are there no instructions to save the workflow?

Answer: Changes to workflows are automatically captured in the database. There is no Save
button (or Update or Submit) because it is not needed.

Workflow Contexts

A context is a workflow’s runtime environment. A context is created when a workflow is


launched. A context loads the workflow definition at time of launch. Regardless of the number of
changes to a workflow definition, contexts continue to run using the workflow definition at the
time of launch. In addition to loading a workflow, contexts also know which record the workflow
was launched for.
Use the Application Navigator in the main ServiceNow browser window to access the context
modules:
 Active Contexts: A list of currently executing contexts

 All Contexts: A list of running, finished, and canceled contexts

OR

Select the Workflow Actions button ( ) in the Workflow Editor and choose the Show
Contexts menu item.
Click the timestamp to open a context.

In the Related Links, click the Show Workflow link. A new tab opens with a color-coded
representation of the workflow in the runtime environment.

Click the Help button in the workflow context header to see the color code.
In the example, the Begin activity is finished and the Approval - User activity is the running
activity. The workflow will stay on the Approval - User activity until the Requested for’s
manager has either approved or rejected the request.

Click the Refresh button ( ) in the workflow context header to update the diagram with the
current status of the workflow.

In this case, the Requested for’s manager rejected the NeedIt request. The workflow followed the
Rejected transition out of the Approval - User activity. The End activity is blue which means the
workflow has completed execution and the workflow context is no longer active.

Workflow contexts are useful for debugging workflows.


Workflow Logging

The workflow context contains a section (tab) called Workflow Log. Some messages are written
to the Workflow Log as part of normal workflow execution.

Use the Log Message activity to write info messages to the Workflow Log.
Workflow developers can add their own logging messages to any workflow activity which has a
Script field. The Workflow API has four logging methods:

 workflow.info

 workflow.warn

 workflow.error

 workflow.debug (must be enabled)

To enable workflow.debug messages, open Workflow > Administration > Properties in the
Application Navigator in the main ServiceNow browser window. If prompted by a message to
change scope, click the To edit this record click here link. Select the Log workflow debug
messages option then click the Save button.

The debug message option was not enabled:


Publishing Workflows

Workflows can have three states:

 Checked out: executes only for the user who has the workflow checked out

 Published: executes for all users and records meeting the workflow conditions

 Unpublished: no longer available for new contexts but may still be running for older
contexts

When a workflow is checked out to a user for development, that version of the workflow runs
only for the user who checked it out. Edits to a workflow are not put into the runtime
environment for all users until the workflow is published. Workflows should not be published
until development is complete and the workflow has been tested.

To publish a workflow, click the Workflow Actions button ( ) in the Workflow Editor and
select the Publishmenu item.

Only one published version of a workflow exists in runtime for new contexts. When a workflow
is invoked, the current workflow definition is loaded into the workflow context.

Exercise: Test and Publish the NeedIt Approval Workflow


In this exercise you will test and publish the NeedIt Approval Workflow.

Preparation

The Approval - User activity requires the Requested for’s manager to approve or reject NeedIt
requests. You need to add a manager to a user record for testing purposes. The User form is part
of the Global scope.

IMPORTANT: If no approvers are found for workflow approval activities, the activity defaults to
approved.

1. In the main ServiceNow browser window (not Studio) use the Application Navigator to
open User Administration > Users.

2. Open the record for Adela Cervantsz.

3. Click the Additional actions menu ( ) and select the Configure > Form Layout menu
item.
4. In the message about scope, click the Edit this section in Global link. This option
changes the scope to Global temporarily. When you leave the form, the scope returns to
NeedIt.

5. Add the Manager field to the User form.

a. Click the Manager field in the Available slushbucket to select it.

b. Click the Add button ( ) to move the Manager field to the Selected slushbucket.
c. Use the Move up ( ) and Move down ( ) buttons to place the Manager field on
the form at the location of your choice.

d. Click the Save button.

2. Make Adela’s manager Fred Luddy.

3. Click the Update button.

Test the NeedIt Approval Workflow - Approve

1. If the NeedIt application is not open in Studio from the last exercise, open it now.

a. In the main ServiceNow browser window use the Application Navigator to open System
Applications > Studio.

b. In the Load Application dialog, click the NeedIt application.

2. If not still open from the last Exercise, open the NeedIt Approval workflow for editing in
Studio.
a. In Studio use the Application Explorer to open Workflow > Workflows > NeedIt
Approval.

b. Verify the workflow is checked out to you.

c. If the workflow is not checked out to you, click the Workflow Actions menu ( ) and
select the Checkoutmenu item.

2. Look up the condition that triggers the NeedIt Approval workflow.

a. Click the Workflow Properties button ( ) in the canvas header.

b. Open the Conditions section (tab).

c. Note the Condition.

2. Create a NeedIt request.

a. In the main ServiceNow browser window (not Studio), open NeedIt > Create New.

b. Configure the new NeedIt request.

c. Set the Requested for to Adela Cervantsz.

d. Set the State field value to Awaiting Approval.

e. For all other fields, use the value of your choice.

f. Click the Submit button.

2. Use the Application Navigator to open Workflow > Live Workflows > Active Contexts.

3. Click the timestamp for the NeedIt Approval workflow context.


4. Examine the Related record field. This field contains the record number of the record for
which the workflow is executing.

5. In the Workflow Executing Activities section (tab), note which activity is currently
executing. The workflow should be stopped on the Request Manager Approval Activity.

6. In the Related Links, click the Show Workflow link. The context workflow should look
like the screenshot. Keep this context workflow tab open so you can come back to it as
you continue testing.

7. Impersonate Adela’s manager and approve the NeedIt request.

a. Impersonate Fred Luddy.

b. In the main ServiceNow browser window, open the User menu by clicking your user
name in the ServiceNow banner. Select the Impersonate User option.
c. In the Search for user field, type Fred.

d. In the drop-down list, click fred.luddy.

e. Examine the User menu in the ServiceNow banner. You should now be Fred Luddy.

f. Approve the NeedIt request.

g. Use the Application Navigator to open Service Desk > My Approvals.

h. Locate the Approval for the NeedIt record with the State field value of Requested.

i. Right-click on the Requested link and select the Approve menu item. OR

j. Click the Requested link to open the record then click the Approve button.

2. Impersonate the System Administrator user.


3. Switch to the tab displaying the Workflow context diagram. Click the Refresh button (
) to update the diagram. The workflow should be complete and should have followed
the Approved transition.

4. Use the Application Navigator to open NeedIt > Open.

5. Open the record you used to test the workflow. Verify the State value is Approved.

Test the NeedIt Approval Workflow - Reject

Using the Test the NeedIt Approval Workflow - Approve steps as a model, test the workflow’s
reject path.

Publish the NeedIt Approval Workflow

The NeedIt Approval workflow is fully tested and functioning as expected. It is time to publish
the workflow so it executes for all users and not just the user who checked out the workflow.

1. Return to the browser window which contains the checked out NeedIt Approval
workflow.

2. Open the Workflow Actions menu ( ) and click the Publish menu item.

3. When publication is complete, the status is updated.


Exercise: Create NeedIt Tasks

In this exercise you will create a before Business Rule to set the State field value on new NeedIt
records to Awaiting Approval. You will also create a NeedIt task table and use the NeedIt
Approval workflow to create the NeedIt task records.

Create the Set State Awaiting Approval Business Rule

In the last Exercise, you manually set the State field value to Awaiting Approval in order to
trigger the NeedIt Approval workflow. In this part of the exercise you will automate setting the
State field value to Awaiting Approval for new NeedIt records.

1. If the NeedIt application is not open in Studio from the last exercise, open it now.

a. In the main ServiceNow browser window use the Application Navigator to open System
Applications > Studio.

b. In the Load Application dialog, click the NeedIt application.

2. Create a Business Rule.

3. In Studio, click the Create Application File button.

4. In the Filter… field enter the text Business OR select Server Development from the
categories in the left hand pane.

5. Select Business Rule in the middle pane as the file type then select the Create button.

6. Configure the Business Rule:

Name: NeedIt Set State Awaiting Approval

Table: NeedIt [x_<your_company_code>_needit_needit]

Active: Selected (checked)

Advanced: Selected (checked)

1. Switch to the When to run section and continue configuring the Business Rule:

When: Before
Insert: Selected (checked)

2. Switch to the Advanced section.

3. Copy this script and paste it into the executeRule function in the Script field. Do not
overwrite the template; paste the script after the Add your code here comment.

current.state = 14;

4. Click the Submit button.

QUESTION: What does a state value of 14 mean? If you aren’t sure, scroll to the Answers
section at the bottom of this page.

Test the Business Rule

1. In the main ServiceNow browser window (not Studio), use the Application Navigator to
open NeedIt > Create New.

2. Configure the new NeedIt record.

a. Set the Requested for to Adela Cervantsz.

b. Leave the State field value at the default value of Requested.

c. Enter the values of your choice in the mandatory fields.

QUESTION: Why do you have to test with Adela Cervantsz as the Requested for? If you aren’t
sure, scroll to the Answers section at the bottom of this page.

2. Click the Additional actions menu ( ) and choose the Save menu item. Do not click
the Submit button as that will navigate away from the form.

3. What value does the State field have after saving? It should be Awaiting Approval. If not,
debug and re-test.
Create the NeedIt Task Table

NeedIt requests are for services from various departments. Each NeedIt request could result in
several tasks which are required to fulfill the request. In this part of the exercise, you will create
a NeedIt Task table. Tasks created to fulfill NeedIt requests will be records on the NeedIt Task
table. For purposes of this exercise, only one NeedIt Task is created for each approved NeedIt
request.

1. Create a table.

a. In Studio, select the Create Application File button.

b. In the Filter… field enter the text Table OR select Data Model from the categories in the
left hand pane.

c. Select Table in the middle pane as the file type then select the Create button.

2. Configure the table:

Label: NeedIt Task

Name: (this field value is automatically populated)

Extends table: Task

Create module: Selected (checked)

Create mobile module: Selected (checked)

Add module to menu: NeedIt

1. Switch to the Controls section and configure the controls:

Auto-number: Selected (checked)

Prefix: NITASK

Number: 3000

Number of digits: 6

User role: (this field value is automatically populated)

2. Switch to the Application Access section and configure the controls:

Accessible from: All application scopes

Can read: Selected (checked)


Can create: Selected (checked)

Can update: Selected (checked)

3. Click the Submit button on the table form.

Modify the NeedIt Task Table Form

1. Create a form for the NeedIt Task table.

a. In Studio, select the Create Application File button.

b. In the Filter… field enter the text Form OR select Forms & UI from the categories in
the left hand pane.

c. Select Form in the middle pane as the file type then select the Next button.

d. Select the NeedIt Task [x_<your_company_code>_needit_needit_task] table.

e. Click the Create button.

2. The State field was inherited from the Task table. The inherited State field choices are not
all relevant to the NeedIt Task table so the choices must be customized.

a. Hover over the State field until the Action buttons appear and click the Edit
Properties button ( ).

b. Remove all of the choices except Open, Work in Progress, and Closed Complete. Click
the Remove button ( ) next to a choice to remove the choice from the list.

c. Close the Properties dialog by clicking the Close button ( ).

2. Add the existing Due date field to the NeedIt Task form.

a. Select the Fields tab in the Field Navigator.

b. Drag the Due date field from the Fields tab to the location of your choice on the form.
2. Remove the Configuration item, Active, and Parent fields from the form. To remove a
field, hover over the field then select the Remove button ( ). The form should look
like this. Your Due date field might be in a different location.

3. Click the Save button on the Form Designer.


Add a Create Task Activity to the NeedIt Approval Workflow

1. If not still open from the last Exercise, open the NeedIt Approval workflow for editing in
Studio.

a. In Studio use the Application Explorer to open Workflow > Workflows > NeedIt
Approval.

b. Verify the workflow is checked out to you.

c. If the workflow is not checked out to you, click the Workflow Actions menu ( ) and
select the Checkoutmenu item.

2. Switch to the Core tab in the Palette.

3. Expand the Tasks category.

4. Locate the Create Task activity.

5. Click, hold, and drag the Create Task activity into the canvas. Hover the activity over the
transition between the Set State to Approved and End activities. When the transition turns
blue, drop the activity.

6. Configure the Create Task activity:

Name: Create NeedIt Task

Task type: NeedIt Task [x_<your_company_code>_needit_needit_task]

Task values from: Values


1. Add a script to set the Short description, Description, Due date, and Assigned to field
values on the NeedIt Task record using values from the NeedIt record.

a. Scroll to the Script section.

b. Click the Advanced option.

c. Paste this script into the Advanced Script field. Paste the script at line 6 (after the
comments in the template).

task.short_description = current.u_request_type + ' : ' + current.u_what_needed + ' : ' +


current.short_description;

task.description = current.description;

task.due_date = current.u_when_needed;

task.assigned_to = "beth.anglin";

d. Click the Submit button.

2. Examine the Workflow. Verify there are transitions into and out of the Create Task
activity. Your workflow layout on the canvas might be different than the layout in the
screenshot. As long as the transitions correctly connect the activities, the layout doesn’t
matter.

Test the NeedIt Approval Workflow - Approve

1. Trigger the workflow.

a. In the main ServiceNow browser window (not Studio), open NeedIt > Create New.

b. Configure the new NeedIt request.


i. Set the Requested for to Adela Cervantsz.

ii. For all other fields, use the value of your choice: Short description, Description, and all
mandatory fields. Do not change the value in the State field value.

iii. Click the Submit button.

2. Use the Application Navigator to open Workflow > Live Workflows > Active Contexts.

3. Click the timestamp for the NeedIt Approval workflow context.

4. Examine the Related record field. This field contains the record number of the record for
which the workflow is executing.

5. In the Workflow Executing Activities section (tab), note which activity is currently
executing. The workflow should be stopped on the Request Manager Approval Activity.

6. In the Related Links, click the Show Workflow link. The Workflow is stopped on the
Approval - User activity.

7. Impersonate Adela’s manager and approve the NeedIt request.

a. Impersonate Fred Luddy.

b. In the main ServiceNow browser window, open the User menu by clicking your user
name in the ServiceNow banner. Select the Impersonate User option.
c. In the Search for user field, type Fred.

d. In the drop-down list, click fred.luddy.

e. Examine the User menu in the ServiceNow banner. You should now be Fred Luddy.

f. Approve the NeedIt request.

g. Use the Application Navigator to open Service Desk > My Approvals.

h. Locate the Approval for the NeedIt record with the State field value of Requested.

i. Right-click on the Requested link and select the Approve menu item. OR

j. Click the Requested link to open the record then click the Approve button.

2. Impersonate the System Administrator user.

3. Switch to the tab displaying the Workflow context diagram. Click the Refresh button (
) to update the diagram. The workflow should be stopped on the Create Task activity.
The Workflow will remain on the Create Task activity until the activity is closed.
4. Use the Application Navigator to open NeedIt > NeedIt Tasks.

5. You should have one NeedIt Task record. Open the record.

6. Examine the NeedIt Task record fields. The Short description, Description, and Due date
fields should have been populated by the Create Task activity based on the values in the
NeedIt request record. If not, debug and re-test.

7. Change the State field value to Closed Complete.

8. Click the Update button.

9. Switch to the tab displaying the Workflow context diagram. Click the Refresh button (
) to update the diagram. The workflow execution should be completed.
Challenge

Modify the NeedIt Approval workflow to set the State field value on the NeedIt request record to
Closed Complete when the NeedIt Task record created by the workflow is Closed Complete. Can
you think of a way to do it without adding any activities to the Workflow? If you aren’t sure,
scroll to the Answers section at the bottom of this page.

Publish the NeedIt Approval Workflow

The NeedIt Approval workflow is fully tested and functioning as expected. It is time to publish
the workflow so it executes for all users and not just the user who checked out the workflow.

1. Return to the browser window which contains the checked out NeedIt Approval
workflow.

2. Open the Workflow Actions menu ( ) and click the Publish menu item.

3. When publication is complete, the status is updated.

Answers

Question: What does a state value of 14 mean?

Answer: All choices in a choice list have a Label and a Value. Humans, lists, and forms use the
human readable Label. Scripts use the Value. For the NeedIt table’s State field, a value of 14
means Awaiting Approval. This screenshot is from the Form Designer. Open the NeedIt form in
Studio (**Forms & UI > Forms > NeedIt [Default view]**). Hover over the State field then click
the Settings button ( ) to see the choice list.
Question: Why do you have to test with Adela Cervantsz as the Requested for?

Answer: If no valid approvers are found, approval requests default to Approved. The only User
in the database with a manager is Adela. The Business Rule you are testing sets the State field
value to Awaiting Approval. For Requested fors with no manager, the State will be Approved
instead of Awaiting Approval because the NeedIt Approval Workflow will run to completion
through the Approved path without waiting for approval.

Question: Modify the NeedIt Approval workflow to set the State field value on the NeedIt
request record to Closed Complete when the NeedIt Task record created by the workflow is
Closed Complete. Can you think of a way to do it without adding any activities to the Workflow?

Answer:

Workflow Module Recap

Core concepts:

 A workflow is a sequence of activities used to automate processes

 The Workflow Editor has:


 Canvas

 Palette

 Title Bar

 Canvas Tabs

 The Core tab contains the available activities organized by category:

 Approvals

 Conditions

 Notifications

 Service Catalog

 Subflows

 Timers

 Utilities

 Workflows should be fully tested before they are published

 Checked out workflow runs for the user who checked it out

 Published workflows run for all users

 A workflow context is the runtime environment for a workflow

 Use contexts to debug workflows

Vous aimerez peut-être aussi