Add selection control to your workflows using the Switch action. With the Switch action,
you can define multiple conditions, each with its own run path. When a condition is met, the
corresponding path is run, while the others are automatically ignored.
About this task
The execution paths are defined using Cases. Each case specifies the
conditions to be met along with the next action to be run if the condition is met.
Cases are evaluated sequentially, beginning with Case 1. When a case meets the condition, the
associated action is run, and the remaining cases are ignored. A default case can be specified,
which runs if none of the conditions in the other cases are met. You can assign the same case
number, for example, Case 2 to multiple execution paths with different conditions. In this
situation, both conditions are evaluated simultaneously, but only the one with a matching condition
is run. If neither condition is met, the next case is evaluated.
Your organization has a support request form on its website where users can submit requests for
different departments. You want to create a workflow that triggers every time a new support request
is raised, checks which department (IT, Operations, Content) the request is for, and sends the
details of the request to the relevant department by using a specific communication channel.
Procedure
-
Configure a trigger that fires off each time a new request is submitted through the request
form.
Select the Formstack - New Submission trigger and configure
it.
- Add the Switch action to the canvas, followed by
Asana, Intercom, and Cisco Webex
Teams connectors.
- Configure Switch cases. Connect Switch with
all the connectors on the canvas.
Case numbers are assigned by default at the time of
connecting the
Switch with connectors. You can change these case numbers
based on your requirements. For this example, set the following conditions.
- If the department is IT, create a new task in Asana.
- If the department is Operations, create a new note in Intercom.
- If the department is Content, post a new message on Cisco Webex Teams space.
- Define the conditions.
Click the line connecting the Switch action and Asana
connector icon and then click the Settings icon. The
Condition window appears on the screen. Here, you can see the Select
Case drop-down menu from where you can add cases and the
Condition block from where you can set specific conditions.
- Select Case - Click the drop-down arrow to see the list of available
cases and select the case that you want to assign to this run path. Cases are evaluated in
sequential order. As we have connected three connectors with Switch, you see
Case 1, Case 2, Case 3, and the Default Case in the drop-down list.
- Condition - Click Add Condition and then click
Add Filter. In the condition block that appears, specify the condition that
you want to set.
- The condition block is configured as follows.
- Input - Add the key name for the value you want to check, from the
Trigger data. Add the Department key.
- Condition - Select the Exactly Matches condition.
- Expected - Enter the value that you want to compare against the form value. Enter IT.
- Click Done. This takes you back to the canvas. Repeat this
procedure.
- Case 2 (Switch and Intercom, where the expected value in condition is Operations.
- Case 3 (Switch and Cisco Webex Teams, where the expected value in condition is Content.
- Configure the actions to retrieve and send the form data if the condition they are
associated with is met. Configure Asana - Create Task, Intercom -
New Note, and Cisco Webex Teams - Post new Message actions by
selecting the relevant accounts.
- In the Body (or other such relevant) field of each action, add the
Trigger Data that are given on the left-side of the configuration window and
click Next.
- Test the action and click Done.
When a user
submits the request form, the Formstack - New Submission trigger activates
the workflow. The Switch action evaluates each case to determine the
department for the request. Based on the matched department, the relevant action is run, sending the
form data to the corresponding department.