Has Operator: Confirming the Path of Multiple Objects

Overview

The Has operator inputs an object and outputs either true or false. The output is dependent on the object's key. If the operator's key matches the object's key, the output is true. If not, the output is false.

In this article, you'll set up 4 Hidden components to input to your Data Workflow. Then, you'll group them using a Group Input operator and pass them into a Has operator. You'll set up the Has operator to look in the Group Input operator for a specific key. If the Has operator finds a match, the output is true. If the operator doesn't find a match, the output is false. In this use case, you'll configure the Has operator's key to be one of your Hidden components.

Remember, you must spell the key correctly or the output will be false. For example, if your key is value2, entering value gives you a false output.

Here's how your module looks in the Module Builder:

Here's how the completed use case looks in Express View, including a peek at the DevTools Console:

What You'll Learn

In this article, you'll learn how to use the Has operator to confirm the key or path of multiple objects.

What You'll Need

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

  • 4 Hidden components

  •  

  • 1 Button component

  • 1 Data Workflow component

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

  • 1 Group Input operator

  • 1 Has operator

  • 2 Console operators

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

Configuration

Configure the Hidden Components

First, you'll set up 4 Hidden components to house your inputs. For each component, you'll enter a different question in the Default Value field.

1. In the Module Builder, drag and drop 4 Hidden components onto your canvas, placing them one after the other.
2. Enter the following Property ID, Canvas Label Text, and Default Value:
Property ID Canvas Label Text Default Value

value1

value1

Who can have the Has?

value2

value2

Or is it, who has the Have?

value3

value3

Does the Get get the Has.

value4

value4

Or, does the Has have the Get?

3. Save each component as you add it.

Configure the Data Workflow Component

Now, you'll set up your Data Workflow. First, you'll add a Group Input operator so you can input all 4 Hidden components together as objects. Then you'll pass these objects through your Has operator, looking specifically for value2. Because the value2 Hidden component exists, your Data Workflow's output is true. You'll set up a couple of Console operators to watch the progress.

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

Configure the Group Input Operator

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

Category

Group Input

Component

value1

Component 1

value2

Component 2

value3

Component 3

value4

Component 4

 

Component 5

 

Required

Yes

Configure the Has Operator

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

Category

Has

Label

Has value2

Path

value2

3. Connect the output port (right) of the Group Input operator to the input port (left) of the Has 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

Group Input

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

Configure the Second Console Operator

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

Category

Console

Label

Group Input Has value2?

3. Connect the lower output port (right) of the Has operator to the input port (left) of the Group Input Has value2? Console operator.
4. Click Save.

Configure the Button Component

Now, add a Button component to trigger your Data Workflow.

1. Drag and drop a Button component onto your canvas, placing it below your Data Workflow.
2. Enter btnHasGroupInput in the Property ID field.
3. Enter Get the Has in the Label field.
4. Select Event as the Action Type.
5. Enter dwfHasGroupInput in the Trigger on Click field.

6. Click Save.
7. Save your module.

Now you can test out your Data Workflow. Open and expand the DevTools Console, and click your Get the Has button. The first Console shows all 4 of your Hidden values, and the second Console shows the result of the Has operator. You can see the output is true because the value2 object exists in the Group Input operator. To confirm other keys, you'll change your Has operator to look for another Hidden value.

Lab

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