Includes Operator

Overview

The Includes operator verifies that your data holds a specific value. With this operator, you can check a single value from a data set or an entire array. Your Includes operator works the same in either situation.

To start, you'll enter the necessary value in the operator's Info window. Then, the operator looks at the data you pass to it to see if it holds that value. If there's a match, the operator outputs true. If there isn't a match, the operator outputs false.

The Includes operator only works with a single value or an array. So, it can't process an entire table. You'll first need to convert your data using another operator. You'll do this using something like a Get operator or a Col2Array operator. Then, you'll use that converted data as the input to your Includes operator.

You’ll find the Includes operator under the Array 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 Includes 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 the operator. The label you enter here appears below the operator in the Data Workflow canvas.

This field is optional, but you'll want to set a label if you're using more than one of the operator type. A label can help you identify your operators without having to open any info windows.

Value

The value your Includes operator looks for in the data passed to it. Think of this as the condition for your operator's final True or False output. If your data holds this value, you'll get true as your output. If your data doesn't hold this value, you'll get false as your output.

Adding an Includes Operator

To show the Includes operator in action, let's look at an example. You'll set up a Data Table with a list of users and their roles. Then, you'll use an Includes operator in your Data Workflow to verify that a specific user has the role of administrator.

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

This use case works behind the scenes, so you won't see anything in Express View outside of the DevTools Console. So, here's a sneak peek at that:

What You'll Need

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

  • 1 Data Table component

  • 1 Initializer component

  • 1 Data Workflow component

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

  • 1 Input operator

  • 1 Get operator

  • 1 Includes operator

  • 1 Console operator

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

Configure the Data Table Component

First, let's add your list of users. You'll use a Data Table component for that.

1. In the Module Builder, drag and drop a Data Table component onto your canvas.
2. Enter dtUsers in the Label and Property Name fields.
3. In the data table, enter the following:
userName role

rmoose

architect

kbell

administrator

rgreen

authenticated

cbing

client

4. Click Save.

Configure the Data Workflow Component

Now, let's set up your Data Workflow. Here, you'll use a Get operator to retrieve the role of the second user in your data table. The Get operator then passes that data to the Includes operator, which verifies that the data holds administrator. Finally, you'll add a Console operator so you can see all of this happen behind the scenes.

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

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

dtUsers

Required

Yes

Source

Default

Configure the Get Operator

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

Setting

Value

Category

Get

Label

Get [1].role

Path

[1].role

NOTE  Keep in mind that indexed values start at [0]. So, the [1] in your path here points the Get operator to the second user in your data table.

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

Configure the Includes Operator

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

Setting

Value

Category

Includes

Label

Includes Administrator

Value

administrator

3. Connect the output port (right) of the Get operator to the input port (left) of the Includes operator.

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

Does [1].role Include Administrator?

3. Connect the output port (right) of the Includes operator to the input port (left) of the Console operator.
4. Click Save.

Configure the Initializer Component

Finally, let's add an Initializer component to trigger your Data Workflow. You'll set this component to trigger on each new submission. So, each time the page loads, your Data Workflow is triggered.

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

dwfIncludesSingleValue

trigger

GO

5. Click Save.
6. Save your module.

Now it's time to preview your module. Preview your module in Express View and open the DevTools Console. You'll see your Does [1].role Include Administrator? Console shows a value of true.

Changing an Includes 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 Includes 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 Includes 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/60492dca6d7bec0249d3ae42/edit.