Service Catalog and Workflow OverviewIssue In this article we'll dive into the following subjects: Assign Workflows to Catalog ItemsAdding Tasks ServiceNow Workflow with Service Catalog One of the most powerful ways of automating a process is to make it available to users through the Service Catalog. A Workflow is associated with a product in the Service Catalog through the Catalog Item definition. Once associated with a Catalog Item, the workflow will run after the SC Request Item that contains the Requested Items is approved.Workflows that are written to process a Catalog Item are associated with Service Catalog Request Item (RITM) table. Through this association the Workflow has access to the variable values of the RITM. Workflows can be written to make decisions based on the values of the RITM variables.As we know, a workflow runs for a specific table. If a workflow needs to leverage RITM variable mapping, the workflow must be associated with the Service Catalog Request Item table.Workflows that are associated with a Catalog Item do not follow the default Workflow Engine behavior as our previous example using Change Request. In the previous example when a Change Request record was inserted, the Workflow Engine examined the conditions of the Workflow, (in our examples Priority-3 or Priority-4). If the conditions were met, the Workflow was automatically started.When using the Service Catalog, the Workflows are associated with the RITM. That RITM however, is part of a Service Request. If the Service Request is not approved or does not succeed, then the RITM that is a part of that Request cannot be allowed to succeed.In this way, the Approval of the SC Request is gating the execution of the workflows associated with the items it contains. For this reason the approval of the SC Request is called the Gateway Approval.Unless and until the SC Request is approved the RITM workflows will not execute. However, the RITM is inserted into the database at the same time as the parent SC Request is.The Workflow associated with the RITM is started from within a series of Business Rules that evaluate the Approval status of the SC Request. Associate a Workflow with a Service Catalog Item Service Catalog > Maintain Items.Select the K14 WF 201 Example – Request Subscription. You may need to switch to the Advanced View.Click on the View name to select the Advanced View.NOTE: The purpose of this lab is to demonstrate the association of Service Catalog and Workflow. Learning how to build Catalogs, Add Items to Catalogs etc. is a part of the Service Catalog track of this conference and is highly recommended for anyone interested in writing workflows for Service Catalog Items.Notice the Workflow field. This field creates the association between the Service Catalog Item and the Workflow assigned to this field. In this case the Workflow assigned is K14 WF 201 Example - Request Subscription. It is this field in the RITM that will be read from inside the Run Workflow Business Rule in the Gateway Approval process we discussed earlier.Scroll to the bottom of the form and find the Variables Related List. There will be 3 records.The variables that belong to this Catalog task are available for read and write within the K14 WF 201 Example - Request Subscription Workflow.Return the Workflow Editor in the adjacent browser tab.Click Open.Select the K14 WF 201 Example - Request Subscription.Your workflow should look like this:Select the Gear Menu > Check OutSelect the Gear Menu > PropertiesThis Workflow is written against the Request Item table. Notice that there are no conditions available for this workflow. Because the Workflow Engine doesn’t evaluate the Request Item Glide Record to determine if it should run or not, there is no point in configuring conditions.QUESTION: If the Workflow Engine does not determine the conditions that run a Workflow against an RITM, what does?Close the Workflow Properties form using the X in the upper right-hand corner.Double-click on the Get Manager Approval Activity.Click the Users Lock icon.Click the Select users (Tree icon) to the right of the entry field. Dot walk to follow this path: Opened by > Department > Department Head.The ${ } notation will interpret the values inside as a dot walk of the current record. In this case, the Current record is an sc_req_item Glide Record that has a reference field opened_by, which is a sys_user reference. The sys_user table has a manager field. The tree is a code assist tool for dot walking to assignment fields within the current record.Click Update on the Approval Form.In the Activities Tree, open the Approvals Category folder and select Approval Action.Drag an Approval Action onto the transition between Approval – User and Log Approved Log Message.The Approval Action is used to set the Approval state of the RITM record based on the outcome of the Approval.Fill out the fields as follows: Name: Manager ApprovedAction: Mark task approved Click Submit.Right-click on the white portion of the Manager Approved Activity.Select Copy Activity.Drag an Approval Action onto the transition between Approval – User and Log Rejected Log Message. Your screen should look like this:Double-click on the duplicated Manager Approved.Fill the form out as follows: Name: Manager RejectedAction: Mark task rejected Click Update.Move the transition endpoint of the Rejected condition to the Approval Action Manager Rejected.Create a transition from Manager Rejected to Log Rejected. Your screen should look like this:In the Activity Tree, expand the Tasks Category folder.QUESTION: There is a new Task in the Tasks folder that was not there earlier for Change Request. What can we assume about the Catalog Task Activity Definition?Drag a Catalog Task onto the transition between Log Approved and End Log Message. Your screen should look like this:Notice the variables in the Slush Bucket. These are the variables that are declared in the Variables Related List of the Catalog Item we looked at earlier. These variables can be moved to the Selected field and provided to the User who will be assigned the task.Select the 3 variables from the Available list and move them to the Selected list.Fill out the rest of the form as follows: Name: Fulfill Subscription TaskAssigned to: K14Task – TwoUserShort description: Magazine Subscription Order FulfillmentInstructions: Please order this magazine Click Submit.Your workflow should look like this:Return to the main ServiceNow tab. Add Service Catalog K14 Category Navigate to Service Catalog > CatalogAdd the Knowledge14 – WF 201 Lab category: Click +.Select Knowledge14 – WF 201 LabPlace in the top dropzone Select the Knowledge 14 - WF 201 Lab category.Select the K14 WF 201 Example – Request Subscription.Accept the default values and select Order Now.Select the link to the RITM.Switch to the Catalog View.Scroll to the Approvers Related ListQUESTION: Looking at the screen capture above and remembering your dot walk assignment in the Approval User Activity, what can we assume about the K14 Manager? Think of your dot walk.Right Click > Approve the K14 Manager approval. Notice that a Catalog Task record has been added and the Stage has updated. The workflow has updated the Stage field.QUESTION: Look at the Stage field. How did the value change from Requested to request_approved?In the Catalog Tasks Related List, open the Task record.QUESTION: How did the variables for the RITM get onto the Catalog Task form?Click Close Task.In the Request Item form, select the Show Workflow link in the Related Links list. Your workflow context should look like this: Summary The Service Catalog and Workflow Engine work together to fulfill Service Catalog Requests. Because of this the Workflow Engine does not evaluate the conditions of a Workflow that is written against the Requested Item [sc_req_item] table. Workflows are assigned to Catalog Items in the Maintain Items module of the Service Catalog Application. When a Catalog Item, that has a workflow assigned to it, is ordered from the Service Catalog, the workflow will not start immediately. The progress of the Request Item (RITM) is waiting behind a Gateway Approval. Once the Gateway Approval has been approved, the Workflow of the RITM is started from within the Run Workflow Business Rule on the sc_req_item. This Business Rule is triggered by an update to the RITM record from a Business Rule on the parent sc_request. So the Workflow Engine knows not to start a workflow that is associated with an RITM from within the Glide event (insert, update, delete or cancel). Instead, the RITM workflows are started by Business Rules pending the Gateway approval of the Service Catalog Request. The Workflow Editor offers Activities that provide a designer a way to access the variable values of the RITM and to read and write values of the current record.