The Includes operator evaluates data for a specific value. If the value is present, it returns true; otherwise, it returns false. This functionality is similar to the Boolean logic check. In some cases, it might be necessary to verify multiple values and convert the data into an array before evaluating the data. For example, consider a data table containing a list of end-users and their respective roles. You might want to confirm that at least one end-user is an administrator. You can convert the role column into an array using the Col2Array operator and use the Includes operator to examine the array.
You’ll find the Includes operator under the Array operators group to the left of the Data Workflow canvas.
Configuration
In this example, you'll learn how to use the Includes operator to confirm a value in an array.
These instructions assume you have a new module open, saved with a title.
Configure the Data Table Component
Begin by adding a Data Table component with a list of end-users and their roles.
In the Module Builder, drag and drop a Data Table component onto your canvas.
In the Property ID field, enter
dtUsers.In the data table, enter the following:
#
A
B
1
userName
role
2
rmoose
architect
3
kbell
administrator
4
rgreen
authenticated
5
cbing
client
.png)
Click Save Component.
Configure the Data Workflow Component
Now, configure your Data Workflow component. Here, you'll use a Col2Array operator to convert the role column of your data table into an array. The Col2Array operator passes that data to the Includes operator, which determines if it contains the administrator role. Lastly, you'll add a Console operator to view the process.
Drag and drop a Data Workflow component onto your canvas, placing it below your
dtUsersData Table component.In the Property ID and Canvas Label Text fields, enter
dwfIncludesArray.From the Trigger Type drop-down, select Watch.
Configure the 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
dtUsers
Required
Yes
Source
Default
Configure the Col2Array Operator
Drag and drop a Col2Array operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Col2Array
Label
Col2Array Role
Preserve Argument Type
(unchecked)Drop Empty
No
Path
role
Default Value
Connect the output port (right) of the
dtUsersInput operator to the input port (left) of theCol2Array RoleCol2Array operator.
Configure the Includes Operator
Drag and drop an Includes operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Includes
Label
Role Array Includes Administrator
Value
administrator
Connect the output port (right) of the
Col2Array RoleCol2Array operator to the input port (left) of theRole Array Includes AdministratorIncludes operator.
Configure the Console Operator
Drag and drop a Console operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Console
Label
Does the role array include administrator?
Connect the output port (right) of the
Role Array Includes AdministratorIncludes operator to the input port (left) of theDoes the role array include administrator?Console operator..png)
Click Save Component.
Save your module.
Here's how your module looks in the Module Builder:
.png)
Because this example runs in the background, you won't see the results unless you open the DevTools Console. Preview your module in Express View and open the DevTools Console, the Includes operator checks the array for the administrator role, and the Does the role array include administrator? Console operator displays the value as true.
.jpg)
The Includes operator evaluates data for a specific value. If the value is present, it returns true; otherwise, it returns false. This functionality is similar to the Boolean logic check. In some cases, it might be necessary to verify multiple values and convert the data into an array before evaluating the data. For example, consider a data table containing a list of end-users and their respective roles. You might want to confirm that at least one end-user is an administrator. You can convert the role column into an array using the Col2Array operator and use the Includes operator to examine the array.
You’ll find the Includes operator under the Array operators group to the left of the Data Workflow canvas.
Configuration
In this example, you'll learn how to use the Includes operator to confirm a value in an array.
These instructions assume you have a new module open, saved with a title.
Configure the Data Table Component
Begin by adding a Data Table component with a list of end-users and their roles.
In the Module Builder, drag and drop a Data Table component onto your canvas.
In the Label and Property Name fields, enter
dtUsers.In the data table, enter the following:
#
A
B
1
userName
role
2
rmoose
architect
3
kbell
administrator
4
rgreen
authenticated
5
cbing
client
.png)
Click Save.
Configure the Data Workflow Component
Now, configure your Data Workflow component. Here, you'll use a Col2Array operator to convert the role column of your data table into an array. The Col2Array operator passes that data to the Includes operator, which determines if it contains the administrator role. Lastly, you'll add a Console operator to view the process.
Drag and drop a Data Workflow component onto your canvas, placing it below your
dtUsersData Table component.In the Canvas Label Text and Property Name fields, enter
dwfIncludesArray.From the Trigger Type drop-down, select Watch.
Configure the 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
dtUsers
Required
Yes
Source
Default
Configure the Col2Array Operator
Drag and drop a Col2Array operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Col2Array
Label
Col2Array Role
Preserve Argument Type
(unchecked)Drop Empty
No
Path
role
Default Value
Connect the output port (right) of the
dtUsersInput operator to the input port (left) of theCol2Array RoleCol2Array operator.
Configure the Includes Operator
Drag and drop an Includes operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Includes
Label
Role Array Includes Administrator
Value
administrator
Connect the output port (right) of the
Col2Array RoleCol2Array operator to the input port (left) of theRole Array Includes AdministratorIncludes operator.
Configure the Console Operator
Drag and drop a Console operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Console
Label
Does the role array include administrator?
Connect the output port (right) of the
Role Array Includes AdministratorIncludes operator to the input port (left) of theDoes the role array include administrator?Console operator..png)
Click Save.
Save your module.
Here's how your module looks in the Module Builder:
.png)
Because this example runs in the background, you won't see the results unless you open the DevTools Console. Preview your module in Express View and open the DevTools Console, the Includes operator checks the array for the administrator role, and the Does the role array include administrator? Console operator displays the value as true.
.jpg)