Overview: Routing Workflows Using SwitchDescription<!-- div.margin{ padding: 10px 40px 40px 30px; } table.tocTable{ border: 1px solid; border-color:#E0E0E0; background-color: rgb(245, 245, 245); padding-top: .6em; padding-bottom: .6em; padding-left: .9em; padding-right: .6em; } table.noteTable{ border:1px solid; border-color:#E0E0E0; background-color: rgb(245, 245, 245); width: 100%; border-spacing:2; } table.internalTable{ border:1px solid; border-color:#E0E0E0; background-color: rgb(245, 245, 245); width: 100%; border-spacing:0; } .sp td{ border-bottom: 1px solid; border-right: 1px solid; border-color:#E0E0E0; background-color: #ffffff; height: 20px; padding-top: .5em; padding-bottom: .5em; padding-left: .5em; padding-right: .5em; } .sphr td{ border-right: 1px solid; border-bottom: 1px solid; border-color:#E0E0E0; background-color: rgb(245, 245, 245); padding-top: .5em; padding-bottom: .5em; padding-left: .5em; padding-right: .5em; height: 20px; } .title { color: #D1232B; font-weight:; font-size:25px; } .hd1{ color: #D1232B; font-weight:; font-size:18px; } .hd2{ color: #646464; font-weight:bold; font-size:16px; } .hd3{ color: #7a7a7a; font-weight:; font-size:16 px; text-decoration:; } .hd4{ color: #000000; font-weight:bold; font-size:14 px; text-decoration:; } --> Overview: Routing Workflows Using Switch GoalUnderstand the Activities available for making decisions in a Workflow based on the values of the Current Record. Routing workflows One of the most powerful aspects of the Workflow Engine is its ability to interact with the platform. For the most part, this interaction is through the manipulation of the Current Record. The Workflow Editor provides Activities that will read specified fields on the Current Record and route the workflow along specific transition paths based on the values of those fields. In the Conditions Category folder, the Switch and If Activities that assist the designer with routing. In the Utilities Category folder, the Branch can be used. Return to the Workflow Editor.Click Open.Select K14 – Choices in Workflow – Switch Demo.Select the Gear Menu > Check Out.Select the Gear Menu > Properties. Notice that this workflow is on the Same K14 301 table used in earlier labs. In this demo, condition that runs the workflow is Name starts with Switch Demo. Close the Properties form.Double click on the If Budget Review Activity. The If Activity contains a simple condition builder. The condition choices are based on the fields that are available in the table associated with the workflow. In this case K14 301 Demo. Take a minute to look back at the form and look at the choices for Review type. Close the Activity form.Double-click on the If Budget Review Activity.Return to the main ServiceNow tab.In the Application Navigator Text filter type, K14.Select a record from the K14 301 list.Select Review Type control. Notice that the Review type has 3 options, Budget Review, Facilities Review and a default of None. Return to the Workflow Editor.Close the Activity.In the Activities Tree, expand the Conditions Category to locate the Switch Activity.Drag the Switch Activity onto the Canvas.Fill out the form as follows: Name: Switch on Review Type Type: Field Field: Review Type Click Submit. Notice that the auto-generated conditions are the same values as the items in the choice list on the K14 301 forms. Using the Switch instead of the If in this situation allows us to route the workflow differently on a None selection. Delete the If by clicking the X on the Activity.Route the Begin to the Switch.Route the Budget Review Condition to the Budget Ok? Approval.Route the Facilities Plan Condition to the Plan OK? Approval.In the Utilities folder in the right panel, find the Log Message.Drag the Log Message onto the canvas.Fill out the form as follows: Name: Error Message: No Review Type Selected Click Submit.Route the None Condition of the Switch to the Error Log Message.Route the Error Log Message to End. Your workflow should look like this: Return to the main ServiceNow tab.Select New on the K14 301 list header.Fill out the form as follows: Name: Switch Demo Review Type: Budget Review Click Submit.Select K14 Approvals. Right click > Approve the Requested Approval.Select K14 Live Workflows.Select the Context that matches the Number of the last K14 301 record.Select Show workflow from the Related Lists. Notice that the Workflow was routed through transitions of the Workflow according the selection in the Review Type selection. Repeat steps 31 - 38 for the None selection. Fill out the form as follows: Name: Switch Demo Review Type: None Repeat steps 31 to 38 for the Facilities Plan selection. Fill out the form as follows: Name: Switch Demo Review Type: Facilities Plan Validate the routing matches the selection. Summary The Workflow Editor offers several ways to route a workflow through transitions based on the data in the Current Record. The If Activity can be configured to evaluate values of fields in the Current Record using a Condition builder. The Switch Activity auto-generates conditions based on the values of a choice list in the Current Record.