The Input Switch operator lets you alternate between two inputs in the same flow of a Data Workflow. To start, you'll connect two Input-type operators to your Input Switch. Then, you'll set a condition for the Input Switch to determine which set of input data to use. When your condition is True, the Input Switch chooses the input connected to its upper input port, and when your condition is False, the Input Switch chooses the input connected to its lower input port.
In other words, you can think of an Input Switch like a reverse Decision operator. A Decision operator has two possible paths for your data to follow. The Decision uses a condition to determine which path to send your data on. In contrast, the Input Switch operator has one possible path with two potential sources of data. And the Input Switch uses a condition to determine which set of data to send on that path.
Input Switch operators only work in a forward direction. So, the operator can't update or edit any data passed to it through its input ports.
You’ll find the Input Switch operator under the Gateways group atot the left of the Data Workflow canvas.
About the Info Window
Here's what the Input Switch operator looks like, along with its Info window:
And here's a breakdown of each setting in the Info window:
Setting | Description |
---|---|
Category | Grayed out and non-adjustable setting indicating the operation type. |
Label | Sets the label for your operator, displaying below the operator on your Data Workflow canvas. This field is optional, but set a label if you use more than one of the same operator type. A label helps you identify your operators without opening any Info windows. |
Do Not Sanitize Formula | When this checkbox is clear, the operator cleans values coming into or defined in the operator. For example, removing special characters. Some of those special characters include Sanitizing improves performance. But it can also lead to unexpected data behavior. If your Create Field is not behaving as expected, try selecting this box. When selected, the operator uses your values and expressions as-is. This is best when working with complex values or values that should remain unchanged. By default, this setting is selected, which means the operator does not attempt to sanitize. |
Preserve Argument Type | When selected, this setting ensures the argument data type is respected when the operator executes. |
Condition | Here, you'll set the expression that the operator runs your data against. You'll use To use another operator as an argument, connect the operator to the argument port. Then, enter |
Adding an Input Switch Operator
To show the Input Switch operator in action, let's look at a simple example. Say you have two Text Fields, and you can use data from either of them in your Data Workflow. You can add a set of Radio Buttons to let your end-user choose which field runs through your Data Workflow. You'll connect both Text Fields as inputs to an Input Switch. Then, you'll connect your Radio Buttons to the argument port of the Input Switch. You'll configure your Data Workflow to show your end-user's selection in a third Text Field.
This is a simplified example to demonstrate the functionality of this operator. For a more detailed use case, reference our Input Switch Use Case: Creating a Comment Array article.
Here's how the completed example looks in the Module Builder:
Here's how the completed use case will look in Express View:
Configure the Columns Component
Your Columns component acts as a container for the components that follow.
Drag and drop a Columns component onto your canvas.
In the Property ID field, enter
colInputs
.Under Formatting, click
(two columns).
Click Save & Close.
Configure the Text Field Components
Next, let's add input and output fields to your module. You'll use Text Fields to collect your end-user's name and job title. And you'll use a third Text Field to show the output of your Data Workflow.
Drag and drop three Text Field components onto your canvas, placing them in the left-hand column of the colInputs Columns component.
Enter the following Property ID and Label Text for each component:
Property ID
Label Text
name
Name
jobTitle
Job Title
output
Output
Click Save & Close as you add and configure them.
Configure the Radio Buttons Component
To let your end-user choose which input they see, you'll add a Radio Buttons component. You'll set this as the argument for your Input Switch in the next step.
Drag and drop a Radio Buttons component onto your canvas, placing it in the right-hand column of the colInputs Columns component.
In the Property ID field, enter
switchArgument
.In the Label Text field, enter
Show:
.Set your Option Label and Value to Store in Submission Data as shown below:
#
Option Label
Value to Store in Submission Data
1
Name
name
2
Job Title
jobTitle
Click Save & Close.
Configure the Data Workflow Component
Now, let's add your Data Workflow. You'll set your Name and Job Title fields as inputs for your Input Switch operator. Your Radio Buttons component serves as the argument. Then, your Input Switch outputs the result to your Output Text Field.
Drag and drop a Data Workflow component onto your canvas, placing it below your colInputs Columns component.
In the Canvas Label Text and Property Name fields, enter
dwfSwitch
.
Configure the First Input Operator
Drag and drop an Input operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Input
Component
name
Required
No
Source
Default
Configure the Second Input Operator
Drag and drop a second Input operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Input
Component
jobTitle
Required
No
Source
Default
Configure the Third Input Operator
Drag and drop a third Input operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Input
Component
switchArgument
Required
Yes
Source
Default
Configure the Input Switch Operator
Drag and drop an Input Switch operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Input Switch
Label
_arg='name'
Do Not Sanitize Formula
Yes (checked)
Preserve Argument Type
Unchecked (no)
Condition
_arg='name'
Connect the output port (right) of the name Input operator to the upper input port (left) of the Input Switch operator.
Connect the output port (right) of the jobTitle Input operator to the lower input port (left) of the Input Switch operator.
Connect the output port (right) of the switchArgument Input operator to the argument port (top) of the Input Switch operator.
Configure the Output Operator
Drag and drop an Output operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Output
Component
output
Action
value
Connect the output port (right) of the Input Switch operator to the input port (left) of the Output operator.
Click Save.
Configure the Initializer Component
You'll notice this Initializer component performs two operations. First, it clears your Output Text Field so it's ready for a new value each time your Data Workflow runs. Second, it starts the Data Workflow. You'll add a Button component to trigger your Initializer in the next step.
Drag and drop an Initializer component onto your canvas, placing it above your Data Workflow component.
In the Property ID and Canvas Label Text fields, enter
initSwitch
.Set the Trigger Type as Manual.
In the Outputs table, enter the following:
#
Property ID
Type
Value
1
output
clear
yes
2
dwfSwitch
trigger
GO
Click Save & Close.
Configure the Button Component
Lastly, let's add a Button component to start the whole operation. When your end-user clicks this button, they'll trigger your Initializer. The Initializer then clears your Output Text Field and starts your Data Workflow.
Drag and drop a Button component onto your canvas, placing it between your jobTitle and output Text Field components.
In the Property ID field, enter
btnSwitch
.In the Label Text field, enter
Start Input Switch
.Set the Action Type to Event.
In the On Click field, enter
initSwitch
.This ties your Button component to the Initializer component you'll add in the next step. What you enter here must match the Property ID you assign to that Initializer.
Click Save & Close.
Save your module.
Now it's time to test your Data Workflow. Preview your module in Express View and enter a name and job title. Then, make a selection from your radio buttons and click your button. You'll see the selected value in your Output field.
Resources
You can view this complete use case here: https://training.unqork.io/#/form/602be72d13f5fb03d3e22a15/edit.
Modify the Decision operator in the Data Workflow's configuration window.