This is the last segment in a four part series of articles focused on using ServiceNow to create richer services in the service catalog. In the prior segments, we discussed what an action-based service is, built the core structure of the service and then used that core structure to create a dynamic rendering of the request form based on the selected action. The first 3 segments gave us a working (albeit limited) service. The missing part that really brings it all together is adding workflow functionality. In this segment, we will create a workflow that uses the value of the action variable to determine which course of action should be taken. It will then manage that service request ticket through completion, including notification to the user.
The first thing we need to do is to create a workflow. We do this by selecting Workflow->Workflow Editor from the ServiceNow console left-menu. This will open a new, mostly blank, window with two options on the top left of the screen.
We will now select the New button at the top left of the screen to create a new workflow to use with our I Need Help service. Once you’ve done this, you will see a screen that looks like the following. It will have a Begin and an End, but nothing in between. Our next steps will be to start populating the workflow with some tasks to make it more interesting.
The first step we need to add to the workflow is the ability to make a choice on which workflow path we will follow, based on the Action field from our service. To do this, we will be adding a Switch statement. The Switch statement is located on the expandable tree-list on the right side of the screen at Activities->Conditions->Switch. Simply click and drag on the Switch statement and move it over the line between the Begin and End statements on the workflow. When the line between them turns blue, you can release and the workflow editor will automatically connect the switch into the workflow and show you a screen to populate the values for the Switch statement.
To fill out the required values on the switch, we give it a meaningful name, we select the type of switch is Variable and then we select our Action field as the variable to switch on. Note that when you click the spyglass, ServiceNow shows you the question text associated with the variable and not the variable name itself. Once complete, click the Submit button.
We are now going to add two more activities to our password reset path of the workflow. The first is Set Values and the second is Notification. With Set Values, we are going to populate the Assignment Group and Short Description of the request item.
For the notification, we are going to notify the user that made the request and provide information back about what was reset.
At this point, our workflow should look similar to the following:
We can now publish our workflow. We do this selecting the gear icon at the top left of the screen and selecting Publish. You will likely get some warnings as we have not filled in stages and still have some switch options that are still open, but these are fine to accept for our purposes.
At this point, there is one final step before we can try out the workflow in the service. We need to go back to our service in the Service Catalog. Here we are going finally populate the Workflow: field on the catalog item form. Once we do this and save the service, we can use the Try It button and select the Password Reset action.
If everything was done right, after filling in the fields and submitting the request form, we should now have a request and a request item we can go an review.
The remainder of the service actions are similar to the one we just created so I will leave it up to you to finish up the completed service. We now have an action-based service that can be used to generate unique request items based on the action selected by the user. While our workflow is fairly trivial, we can use this same concept to add workflow activities that allow us to automatically perform different functions both within the ServiceNow platform and through backend service called via REST or Web Services.
I hope this series of articles was useful.