Decision Operator

Overview

The Decision operator is like a fork in the road for your data workflow. This operator compares your data against a condition or expression you set. Then, the operator decides whether that data meets your criteria. If the data meets your criteria, the operator passes the data through the upper output port. If the data doesn't match, the operator sends the data through the lower output port. Think of these outputs as True or False statements. The upper output port states, yes, the data meets your criteria (True). And the lower output port states, no, the data doesn't meet your criteria (False). So, you'll connect operators to these outputs based on what you want to happen based on those results.

To configure a Decision operator, you'll set a Condition in the operator's Info window. To do this, you'll enter a statement using <, >, =, >=, or <=. For example, you can check whether an end-user's income is greater than a certain amount. In this case, your condition might look like A > 100000, where A is your input data and 100000 is the income threshold. In more advanced use cases, you might use an OR statement in your condition. For example, OR(A="a",A="b",A="c"). Here, your operator marks data matching a, b, or c as True while all other data is False.

NOTE  Decision operators only pass data through one output port at a time. The output port that doesn't receive data will show as _BLOCKED. And steps connected to the blocked port will not fire.

You can also set a Condition using an argument. For that, you'd connect another operator to the Decision operator's argument port. Then, you'd type _arg in the Condition field.

NOTE  To set a Condition using an argument, the argument operator must output either a string or a boolean value. This must match the same format as above, using <, >, =, >=, or <=. In other words, the Condition must either be TRUE or FALSE.

You'll find the Input operator under the Gateways group to the left of your canvas.

What You'll Learn

In this article, you'll learn:

About the Info Window

Here's what the Decision 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.

Input List

This drop-down shows available data sources connected to your Decision's input port. Here, you'll select the Property ID for the data you want your Decision operator to process. This selection should match the Property ID you've selected in your Input operator.

NOTE  This field is optional. But making a selection here shows a label below your operator. These labels can help to keep your canvas organized.

Condition

Here, you'll set the expression the operator runs your data against. You'll use <, >, =, >=, or <= to set your expression. You can also use a combination of these set inside an OR statement. For example, OR(A="a",A="b",A="c").

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

Adding a Decision Operator

To show a Decision operator in action, let's look at an example. You'll create a module that collects an end-user's income. Then, you'll use a Data Workflow to recommend a financial advisor to your end-user based on that income.

Here's how the completed use case will look in the Module Builder:

Here's how the completed use case will work in Express View along with a look at the DevTools Console:

What You'll Need

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

  • 1 Columns component

  • 1 Number component

  • 1 Text Field component

  • 1 Data Workflow component

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

  • 1 Input operator

  • 1 Decision operator

  • 2 Console operators

  • 2 Create Value operators

  • 2 Output operators

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. In the Module Builder, drag and drop a Columns component onto your canvas.
2. Enter colAdvisor in the Property ID field.
3. Under Column Layout, click the icon showing 2 evenly spaced columns.

4. Click Save.

Configure the Number Component

To collect the income of your end-user, you'll use a Number component.

1. Drag and drop a Number component onto your canvas. Place your Number component in your left-hand column.
2. Enter income in the Property ID field.
3. Enter Current Household Income in the Label Text field.
4. Set the Format as Currency toggle to ON.
5. Set the Show Thousands Separator toggle to ON.

6. Click Save.

Configure the Text Field Component

You'll use a Text Field as the output for your Data Workflow. Here, your end-user sees their recommended financial advisor. Since your end-user won't input data here on their own, you'll set this field as read-only.

1. Drag and drop a Text Field component onto your canvas. Place your Text Field in your right-hand column.
2. Enter financialAdvisor in the Property ID field.
3. Enter Recommended Financial Advisor in the Label Text field.
4. Set the Read Only View toggle to ON.

5. Click Save.

Configure the Data Workflow Component

Now, you'll set up your Data Workflow. You'll use an Input operator to bring in your end-user's income. Then, you'll use a Decision operator to determine which financial advisor to recommend. You'll also include Console operators to see what's happening behind the scenes.

1. Drag and drop a Data Workflow onto your canvas. Place your Data Workflow below your columns.
2. Enter dwfFinancialAdvisor in the Canvas Label Text and Property Name fields.
3. Set the Trigger Type to Watch.

Configure the 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

income

Required

Yes

Source

Default

Configure the Decision Operator

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

Setting

Value

Category

Decision

Input List

income

Condition

A > 100000

3. Connect the output port (right) of the Input operator to the input port (left) of the Decision operator.

Configure the First Create Value Operator

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

Setting

Value

Category

Create Value

Label

Decision True

Expression/Value

"Andrea Matthews"

3. Connect the upper output port (right) of the Decision operator to the top port of the Decision True Create Value operator.

Configure the First 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

financialAdvisor

Action

value

3. Connect the output port (right) of the Decision True Create Value operator to the input port (left) of the financialAdvisor Output operator.

Configure the First Console Operator

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

Setting

Value

Category

Console

Label

Console Decision True

3. Connect the upper output port (right) of the Decision operator to the input port (left) of the Console Decision True Console operator.

Configure the Second Create Value Operator

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

Setting

Value

Category

Create Value

Label

Decision False

Expression/Value

"Rachel Moose"

3. Connect the lower output port (right) of the Decision operator to the top port of the Decision False Create Value operator.

Configure the Second Output Operator

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

Setting

Value

Category

Output

Component

financialAdvisor

Action

value

3. Connect the output port (right) of the Decision False Create Value operator to the input port (left) of the second financialAdvisor Output operator.

Configure the Second Console Operator

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

Setting

Value

Category

Console

Label

Console Decision False

3. Connect the lower output port (right) of the Decision operator to the input port (left) of the Console Decision False Console operator.
4. Click Save.
5. Save your module.

Now you can test your Data Workflow. Preview your module in Express View and enter a value in your Current Household Income field. You'll see the Recommended Financial Advisor update in real-time depending on your entered income. And if you take a look at the DevTools Console, you'll see the value that doesn't apply to your data shows as _BLOCKED.

Changing a Decision 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 a Decision 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 a Decision 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/601038452b56d8025c326a15/edit.