How to: Create a Comment Array Using the Input Switch Operator

Prev Next

The Input Switch operator lets you configure a single Data Workflow path with two inputs. The operator determines which input to use based on a condition.

Configuration

In this how-to guide, you’ll use the Input Switch operator to create an array of received comments in your application. Doing so requires a Create Table operator and an Input operator to add new comments to those already received. To switch between these inputs, you'll add an Input Switch operator.

Configure the Text Area Component

Begin by adding a Text Area component where end-users can enter comments.

  1. In the Module Builder, drag and drop a Text Area component onto your canvas.

  2. In the Property ID field, enter comment.

  3. In the Label Text field, enter Comment.

  4. Click Save Component.

Configure the Initializer Component

Next, configure an Initializer component to clear your Text Area component after each comment. You’ll trigger this Initializer component using a Data Workflow you’ll configure in later steps.

  1. Drag and drop an Initializer component onto your canvas, placing it above your comment Text Area component.

  2. In the Property ID and Canvas Label Text fields, enter initClear.

  3. In the Outputs table, enter the following:

    #

    Source

    Type

    Value

    1

    comment

    clear

    yes

  4. Click Save Component.

Configure the Hidden Component

Next, configure a Hidden component to store the output of your Data Workflow.

  1. Drag and drop a Hidden component onto your canvas, placing it below your comment Text Area component.

  2. In the Property ID and Label Text fields, enter commentsTable.

  3. Click Save Component.

Configure the Data Workflow Component

Now configure your Data Workflow. In this example, you'll use many operators to collect your end-user's information and append it. The Input Switch operator plays a crucial role in this configuration. You'll connect a Create Table operator to fire when you receive your first comment. Later, you'll connect an Input operator to reference your commentsTable Hidden component. Then, you'll use a Size operator to determine if your Hidden component stores any comments or if it's empty. This Size operator serves as the argument for your Input Switch operator. So, if your Hidden component has a size greater than 0, the Input Switch chooses that as the input. Doing so lets you keep all your comments in one place. If your Hidden component is empty, the Input Switch chooses your Create Table operator instead.

Your Input Switch uses your Create Table operator only for the first comment. For every comment that follows, the Input Switch chooses your Hidden component.

  1. Drag and drop a Data Workflow component onto your canvas, placing it between your comment Text Area and commentsTable Hidden components.

  2. In the Property ID and Canvas Label Text fields, enter dwfAddComment.

Configure the First Input Operator

  1. Drag and drop an Input operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Input

    Component

    comment

    Required

    No

    Source

    Default

Configure the First Create Table Operator

  1. Drag and drop a Create Table operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Create Table

    Label

    New Comment

    Create Index

    No

    Number of Rows

    1

Configure the First Create Field Operator

  1. Drag and drop a Create Field operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Formula

    Label

    Add Comment

    Do Not Sanitize Formula

    (unchecked)

    Preserve Argument Type

    (unchecked)

    Field 1

    comment=_arg

    Field 2

    Field 3

    Field 4

    Field 5

  3. Connect the output port (right) of the comment Input operator to the argument port (top) of the Add Comment Create Field operator.

  4. Connect the output port (right) of the New Comment Create Table operator to the input port (left) of the Add Comment Create Field operator.

Configure the Second Input Operator

  1. Drag and drop a second Input operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Input

    Component

    currentUser

    Required

    No

    Source

    Default

Configure the Get Operator

  1. Drag and drop a Get operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Get

    Label

    Get Name

    Path

    name

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

Configure the Second Create Field Operator

  1. Drag and drop a second Create Field operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Formula

    Label

    Add Name

    Do Not Sanitize Formula

    (unchecked)

    Preserve Argument Type

    (unchecked)

    Field 1

    writtenBy=_arg

    Field 2

    date = moment(moment(),'format', 'MM/DD/YYYY')

    Field 3

    Field 4

    Field 5

  3. Connect the output port (right) of the Add Comment Create Field operator to the input port (left) of the Add Name Create Field operator.

  4. Connect the output port (right) of the Get Name Get operator to the argument port (top) of the Add Name Create Field operator.

Configure the Third Input Operator

This Input operator serves as the first input for your Input Switch operator. It brings in any existing comments in your array. If you do not have any comments, then the Input Switch operator chooses a different input.

  1. Drag and drop a third Input operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Input

    Component

    commentsTable

    Required

    No

    Source

    Default

Configure the Size Operator

This Size operator determines whether your commentsTable Hidden component stores any data. This serves as the argument for the Input Switch operator.

  1. Drag and drop a Size operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Size

    Label

    Number of Comments

  3. Connect the output port (right) of the commentsTable Input operator to the input port (left) of the Number of Comments Size operator.

Configure the Second Create Table Operator

This Create Table operator serves as the second input for your Input Switch operator. If you do not have any existing comments in your array, the Input Switch operator chooses this input.

  1. Drag and drop a second Create Table operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Create Table

    Label

    First Comment

    Create Index

    Number of Rows

Configure the Input Switch Operator

The Input Switch operator determines whether you have an existing array of comments or if you're starting with your very first comment. It uses the Size operator as an argument, choosing between your commentsTable Input or First Comment Create Table operators.

  1. Drag and drop an Input Switch operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Input Switch

    Label

    If Comments Exist

    Do Not Sanitize Formula

    (unchecked)

    Condition

    _arg > 0

  3. Connect the output port (right) of the commentsTable Input operator to the upper input port (left) of the If Comments Exist Input Switch operator.

  4. Connect the output port (right) of the First Comment Create Table operator to the lower input port (left) of the If Comments Exist Input Switch operator.

  5. Connect the output port (right) of the Number of Comments Size operator to the argument port (top) of the If Comments Exist Input Switch operator.

Configure the Append Operator

  1. Drag and drop an Append operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Append

    Label

    Append Tables

  3. Connect the output port (right) of the If Comments Exist Input Switch operator to the upper input port (left) of the Append Tables Append operator.

  4. Connect the output port (right) of the Add Name Create Field operator to the lower input port (left) of the Append Tables Append operator.

Configure the First Output Operator

  1. Drag and drop an Output operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Output

    Component

    commentsTable

    Action

    value

  3. Connect the output port (right) of the Append Tables Append operator to the input port (left) of the commentsTable Output operator.

Configure the Second Output Operator

  1. Drag and drop a second Output operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Output

    Component

    initClear

    Action

    trigger

  3. Connect the output port (right) of the Append Tables Append operator to the input port (left) of the initClear Output operator.

Configure the Console Operator

  1. Drag and drop a Console operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Console

    Label

    Final Table

  3. Connect the output port (right) of the Append Tables Append operator to the input port (left) of the Final Table Console operator.

    A static image displaying the Input Switch operation to manage comments in a Data Workflow.

  4. Click Save Component.

Configure the Button Component

Lastly, configure a Button component to trigger your Data Workflow.

  1. Drag and drop a Button component onto your canvas, placing it between your comment Text Area and dwfAddComment Data Workflow components.

  2. In the Property ID field, enter btnAddComment.

  3. In the Label Text field, enter Add Comment.

  4. From the Action Type drop-down,  select Event.

  5. From the On Click drop-down, select dwfAddComment.

    A static image displaying the Button configuration for adding comments with event triggers and action types displayed.

  6. Click Save Component.

  7. Save your module.

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

A static image displaying the Module Builder configuration with comment section and buttons for adding comments.

Preview your module in Express View and open the DevTools Console. Enter a comment to view it in the Console. Then, enter another comment and click Add Comment. You'll see your new comment added to the same array as your first comment. That way, all your comments exist in one place so you can reference them later.

The Input Switch operator lets you configure a single Data Workflow path with two inputs. The operator determines which input to use based on a condition.

Configuration

In this how-to guide, you’ll use the Input Switch operator to create an array of received comments in your application. Doing so requires a Create Table operator and an Input operator to add new comments to those already received. To switch between these inputs, you'll add an Input Switch operator.

Configure the Text Area Component

Begin by adding a Text Area component where end-users can enter comments.

  1. In the Module Builder, drag and drop a Text Area component onto your canvas.

  2. In the Property ID field, enter comment.

  3. In the Label Text field, enter Comment.

  4. Click Save & Close.

Configure the Initializer Component

Next, configure an Initializer component to clear your Text Area after each comment. To do so, you must trigger this Initializer in your Data Workflow in the later steps.

  1. Drag and drop an Initializer component onto your canvas, placing it above your comment Text Area component.

  2. In the Property ID and Canvas Label Text fields, enter initClear.

  3. In the Outputs table, enter the following:

    Property ID

    Type

    Value

    comment

    clear

    yes

    A static image displaying the Initializer component settings for a property ID with clear comment output option.

  4. Click Save & Close.

Configure the Hidden Component

Next, configure a Hidden component to store the output of your Data Workflow.

  1. Drag and drop a Hidden component onto your canvas, placing it below your comment Text Area component.

  2. In the Property ID and Canvas Label Text fields, enter commentsTable.

  3. Click Save.

Configure the Data Workflow Component

Now configure your Data Workflow. In this example, you'll use many operators to collect your end-user's information and append it. The Input Switch operator plays a crucial role in this configuration. You'll connect a Create Table operator to fire when you receive your first comment. Later, you'll connect an Input operator to reference your commentsTable Hidden component. Then, you'll use a Size operator to determine if your Hidden component stores any comments or if it's empty. This Size operator serves as the argument for your Input Switch operator. So, if your Hidden component has a size greater than 0, the Input Switch chooses that as the input. Doing so lets you keep all your comments in one place. If your Hidden component is empty, the Input Switch chooses your Create Table operator instead.

Your Input Switch uses your Create Table operator only for the first comment. For every comment that follows, the Input Switch chooses your Hidden component.

  1. Drag and drop a Data Workflow component onto your canvas, placing it between your comment Text Area and commentsTable Hidden components.

  2. In the Canvas Label Text and Property Name fields, enter dwfAddComment.

Configure the First Input Operator

  1. Drag and drop an Input operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Input

    Component

    comment

    Required

    No

    Source

    Default

Configure the First Create Table Operator

  1. Drag and drop a Create Table operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Create Table

    Label

    New Comment

    Create Index

    No

    Number of Rows

    1

Configure the First Create Field Operator

  1. Drag and drop a Create Field operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Formula

    Label

    Add Comment

    Do Not Sanitize Formula

    (unchecked)

    Preserve Argument Type

    (unchecked)

    Field 1

    comment=_arg

    Field 2

    Field 3

    Field 4

    Field 5

  3. Connect the output port (right) of the comment Input operator to the argument port (top) of the Add Comment Create Field operator.

  4. Connect the output port (right) of the New Comment Create Table operator to the input port (left) of the Add Comment Create Field operator.

Configure the Second Input Operator

  1. Drag and drop a second Input operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Input

    Component

    currentUser

    Required

    No

    Source

    Default

Configure the Get Operator

  1. Drag and drop a Get operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Get

    Label

    Get Name

    Path

    name

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

Configure the Second Create Field Operator

  1. Drag and drop a second Create Field operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Formula

    Label

    Add Name

    Do Not Sanitize Formula

    (unchecked)

    Preserve Argument Type

    (unchecked)

    Field 1

    writtenBy=_arg

    Field 2

    date = moment(moment(),'format', 'MM/DD/YYYY')

    Field 3

    Field 4

    Field 5

  3. Connect the output port (right) of the Add Comment Create Field operator to the input port (left) of the Add Name Create Field operator.

  4. Connect the output port (right) of the Get Name Get operator to the argument port (top) of the Add Name Create Field operator.

Configure the Third Input Operator

This Input operator serves as the first input for your Input Switch operator. It brings in any existing comments in your array. If you do not have any comments, then the Input Switch operator chooses a different input.

  1. Drag and drop a third Input operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Input

    Component

    commentsTable

    Required

    No

    Source

    Default

Configure the Size Operator

This Size operator determines whether your commentsTable Hidden component stores any data. This serves as the argument for the Input Switch operator.

  1. Drag and drop a Size operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Size

    Label

    Number of Comments

  3. Connect the output port (right) of the commentsTable Input operator to the input port (left) of the Number of Comments Size operator.

Configure the Second Create Table Operator

This Create Table operator serves as the second input for your Input Switch operator. If you do not have any existing comments in your array, the Input Switch operator chooses this input.

  1. Drag and drop a second Create Table operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Create Table

    Label

    First Comment

    Create Index

    Number of Rows

Configure the Input Switch Operator

The Input Switch operator determines whether you have an existing array of comments or if you're starting with your very first comment. It uses the Size operator as an argument, choosing between your commentsTable Input or First Comment Create Table operators.

  1. Drag and drop an Input Switch operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Input Switch

    Label

    If Comments Exist

    Do Not Sanitize Formula

    (unchecked)

    Condition

    _arg > 0

  3. Connect the output port (right) of the commentsTable Input operator to the upper input port (left) of the If Comments Exist Input Switch operator.

  4. Connect the output port (right) of the First Comment Create Table operator to the lower input port (left) of the If Comments Exist Input Switch operator.

  5. Connect the output port (right) of the Number of Comments Size operator to the argument port (top) of the If Comments Exist Input Switch operator.

Configure the Append Operator

  1. Drag and drop an Append operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Append

    Label

    Append Tables

  3. Connect the output port (right) of the If Comments Exist Input Switch operator to the upper input port (left) of the Append Tables Append operator.

  4. Connect the output port (right) of the Add Name Create Field operator to the lower input port (left) of the Append Tables Append operator.

Configure the First Output Operator

  1. Drag and drop an Output operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Output

    Component

    commentsTable

    Action

    value

  3. Connect the output port (right) of the Append Tables Append operator to the input port (left) of the commentsTable Output operator.

Configure the Second Output Operator

  1. Drag and drop a second Output operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Output

    Component

    initClear

    Action

    trigger

  3. Connect the output port (right) of the Append Tables Append operator to the input port (left) of the initClear Output operator.

Configure the Console Operator

  1. Drag and drop a Console operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Console

    Label

    Final Table

  3. Connect the output port (right) of the Append Tables Append operator to the input port (left) of the Final Table Console operator.

    A static image displaying the Input Switch operation to manage comments in a Data Workflow.

  4. Click Save.

Configure the Button Component

Lastly, configure a Button component to trigger your Data Workflow.

  1. Drag and drop a Button component onto your canvas, placing it between your comment Text Area and dwfAddComment Data Workflow components.

  2. In the Property ID field, enter btnAddComment.

  3. In the Label Text field, enter Add Comment.

  4. Set the Action Type as Event.

  5. From the On Click drop-down, select dwfAddComment.

    A static image displaying the Button configuration settings with options for actions and user feedback displayed.

  6. Click Save & Close.

  7. Save your module.

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

A static image displaying the Classic Designer Module Builder configuration for adding comments and clearing input.

Preview your module in Express View and open the DevTools Console. Enter a comment to view it in the Console. Then, enter another comment and click Add Comment. You'll see your new comment added to the same array as your first comment. That way, all your comments exist in one place so you can reference them later.