Input Switch Operator

Overview

The Input Switch operator lets you alternate between 2 inputs in the same flow of a Data Workflow. To start, you'll connect 2 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. 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 2 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 1 possible path with 2 potential sources of data. And the Input Switch uses a condition to determine which set of data to send on that path.

NOTE  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 at the left of the Data Workflow canvas.

What You'll Learn

In this article, you'll learn:

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. The label you enter here shows beneath your 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 does its best to clean up values coming into or defined in the operator. For example, removing special characters. Some of those special characters include ', $, #, &amp. The operator also cleans up complex values. For example, logically breaking up strings of numbers and letters using underscores. A sample module ID can go from "5f6b4cdfabf886024d4de2d3" to "5f_6b_4cdfabf_886024d_4de_2d_3".

Sanitizing improves performance. But, it can also lead to unexpected data behavior. If your Create Field isn't 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 doesn't attempt to sanitize.

Condition

Here, you'll set the expression the operator runs your data against. You'll use <, >, =, >=, or <= to set your expression.

To use another operator as an argument, connect the operator to the argument port. Then, enter _arg here.

Adding an Input Switch Operator

To show the Input Switch operator in action, let's look at a simple example. Say you have 2 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.

NOTE  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 use case will look in the Module Builder:

Here's how the completed use case will look in Express View:

What You'll Need

To set up this use case, you’ll need:

  • 1 Columns components

  • 3 Text Field components

  • 1 Radio Buttons component

  • 1 Initializer component

  • 1 Button component

  • 1 Data Workflow component

To set up your Data Workflow, you'll need:

  • 3 Input operators

  • 1 Input Switch operator

  • 1 Output operator

NOTE  These instructions assume you have a new module open, saved, and with a title.

Configure the Columns Component

Your columns act as containers for the components that follow.

1. Drag and drop a Columns component onto your canvas.
2. Enter colInfo in the Property ID field.
3. Under Column Layout, click the icon showing 2 evenly-spaced columns.

4. Click Save.

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.

1. Drag and drop 2 Text Field components onto your canvas. Place your Text Fields in your left-hand column.
2. Enter the following Property IDs and Label Text:
Property ID Label Text

name

Name

jobTitle

Job Title

output

Output

3. Click Save.

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.

1. Drag and drop a Radio Buttons component onto your canvas. Place your Radio Buttons in your right-hand column.
2. Enter switchArgument in the Property ID field.
3. Enter Show: in the Label Text field.
4. Set your Option Label and Value to Store in Submission Data as shown below:

Option Label

Value to Store in Submission Data

Name

name

Job Title

jobTitle

5. Click Save.

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.

1. Drag and drop a Data Workflow component onto your canvas. Place your Data Workflow below your columns.
2. Enter dwfSwitch in the Canvas Label Text and Property Name fields.

Configure the First Input Operator

1. Drag and drop an Input operator onto your Data Workflow canvas.
2. Configure the Input operator's Info window as follows:

Setting

Value

Category

Input

Component

name

Required

No

Source

Default

Configure the Second Input Operator

1. Drag and drop a second Input operator onto your Data Workflow canvas.
2. Configure the Input operator's Info window as follows:

Setting

Value

Category

Input

Component

jobTitle

Required

No

Source

Default

Configure the Third Input Operator

1. Drag and drop a third Input operator onto your Data Workflow canvas.
2. Configure the Input operator's Info window as follows:

Setting

Value

Category

Input

Component

switchArgument

Required

Yes

Source

Default

Configure the Input Switch Operator

1. Drag and drop an Input Switch operator onto your Data Workflow canvas.
2. Configure the Input Switch operator's Info window as follows:

Setting

Value

Category

Input Switch

Label

_arg='name'

Do Not Sanitize Formula

Yes (checked)

Condition

_arg='name'

3. Connect the output port (right) of the name Input operator to the upper input port (left) of the Input Switch operator.
4. Connect the output port (right) of the jobTitle Input operator to the lower input port (left) of the Input Switch operator.
5. Connect the output port (right) of the switchArgument Input operator to the argument port (top) of the Input Switch operator.

Configure the Output Operator

1. Drag and drop an Output operator onto your Data Workflow canvas.
2. Configure the Output operator's Info window as follows:

Setting

Value

Category

Output

Component

output

Action

value

3. Connect the output port (right) of the Input Switch operator to the input port (left) of the Output operator.
4. Click Save.

Configure the Initializer Component

You'll notice this Initializer component performs 2 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.

1. Drag and drop an Initializer component onto your canvas. Place your Initializer above your Data Workflow.
2. Enter initSwitch in the Property ID and Canvas Label Text fields.
3. Select Manual as the Trigger Type.
4. In the Outputs table, enter the following:
Property ID Type Value

output

clear

yes

dwfSwitch

trigger

GO

5. Click Save.

Configure the Button Component

Finally, 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.

1. Drag and drop a Button component onto your canvas. Place your Button between your Job Title and Output Text Fields.
2. Enter btnSwitch in the Property ID field.
3. Enter Start Input Switch in the Label Text field.
4. Select Event as the Action Type.
5. Enter initSwitch in the Trigger on Click field.

NOTE  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.

6. Click Save.
7. 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.

Changing an Input Switch Operator's Settings

You can revisit and make changes to this operator.

1. Click the Data Workflow component.

A 5-button toolbar displays above the component on hover-over.

2. Click the (Settings) button to open the Data Workflow canvas.
3. Click the operator to open its Info Window.
4. Make changes to the operator's settings as needed.
5. Click Save.
6. Save your module.

Copying an Input Switch Operator

You can make a copy of your operator using familiar keyboard settings. You can copy and paste an exact copy of your operator, matching all settings.

1. Hover over the Data Workflow component.

A 5-button toolbar displays above the component on hover-over.

2. Click the (Settings) button to open the Data Workflow canvas.
3. Click the operator you want to duplicate.
4. On your keyboard, press Command + C (Mac OS) or Ctrl + C (Windows/Linux) to copy the operator.

TIP  You can copy more than one operator at a time. Hold Command or Ctrl on your keyboard and click all the operators you want to copy. Follow the rest of the steps as usual.

5. On your keyboard, press Command + V (Mac OS) or Ctrl + V (Windows/Linux) to paste the copied operator(s) to the Data Workflow canvas.
6. Click Save.
7. Save your module.

TIP  Did you know you can copy an operator and paste it into a different Data Workflow? You'll use the same steps outlined above.

Removing an Input Switch Operator

Lastly, you can delete this operator from your Data Workflow canvas. You can also use these same steps to delete a connection between two operators.

1. Hover over the Data Workflow component.

A 5-button toolbar displays above the component on hover-over.

2. Click the (Settings) button to open the Data Workflow canvas.
3. Click the operator you want to delete.
4. On your keyboard, press Delete.

NOTE  Once you delete this operator, make sure to connect your remaining operators. If your Data Workflow path doesn't end with an Output or Console operator, your Data Workflow won't work. So, once you delete an operator, make sure to update any remaining paths to end at an Output or Console operator.

5. Click Save.
6. Save your module.

Lab

You can view this complete use case here: https://training.unqork.io/#/form/602be72d13f5fb03d3e22a15/edit.