Create Field Operator

Prev Next

The Create Field operator is a multi-purpose function that creates fields. Creators can also use the Create Field operator to:

  • Dynamically add key/value pairs based on your end-user's input.

  • Add key/value pairs with values based on the value of another field. For example, creating a field with a value calculated using the value from another field.

  • Add key/value pairs with a conditional value. For example, adding one of two possible values based on a conditional if/then expression.

  • Update existing fields in a Data Table component.

You'll find the Create Field operator in the Table group to the left of the Data Workflow canvas.

About the Info Window

Learn more about each setting in the Create Field operator's Info window:

Setting

Description

Category

Grayed out and non-adjustable setting indicating the operation type.

Label

Sets the label for your operator, displaying below the operator on your Data Workflow canvas.

This field is optional, but set a label if you use more than one of the same operator type. A label helps you identify your operators without opening any Info windows.

Do Not Sanitize Formula

When this checkbox is clear, the operator cleans values coming into or defined in the operator. For example, removing special characters. Some of those special characters include ', $, #, and &amp. The operator also cleans up complex values. For example, logically breaking up strings of numbers and letters using underscores. A sample module ID can go from 5f6b4cdfabf886024d4de2d3 to 5f_6b_4cdfabf_886024d_4de_2d_3.

Sanitizing improves performance. But it can also lead to unexpected data behavior. If your Create Field is not behaving as expected, try selecting this box. When selected, the operator uses your values and expressions as-is. This is best when working with complex values or values that should remain unchanged.

By default, this setting is selected, which means the operator does not attempt to sanitize.

Preserve Argument Type

When selected, this setting ensures the argument data type is respected when the operator executes.

Field 1-5

The Create Field operator has five different field options, letting Creators add multiple fields using a single operator.

Define the field you want to create or update, using the following format: key=value. For string values, add single or double quotes around the value. For example, employed="yes".

The value part of the key=value expression can also include calculations, conditional expressions, and references to other fields. It can also reference values coming into the argument port, using the alias _arg. For example, this expression that uses a calculation: incomeMonthly=_arg/12. The calculation happens on the input coming into the operator's argument port.

Or this one, that includes a conditional expression, a reference to another field, and a calculation:lowIncome=IF(incomeAnnual<24000,"yes","no"). Conditional expressions should use the following format: key=IF(condition,valueIfTrue,valueIfFalse).

How your data iterates through your Data Workflow depends on the type of key/value pairs you enter in these fields. This iteration order depends on the keys used:

  • Positive integer-like keys are displayed in ascending order.

  • String keys are displayed in insertion order.

  • Symbol keys are displayed in insertion order.

To learn more, view the ECMAScript language here: https://tc39.es/ecma262/#sec-ordinaryownpropertykeys.

Adding a Create Field Operator

In this example, you'll learn how to add the same key/value pairs to every row in a table.

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

Configure the Data Table Component

First, add a Data Table component to contain your key/value pairs.

  1. In the Module Builder, drag and drop a Data Table component onto your canvas.

  2. In the Property ID field, enter dtTable.

  3. In the data table, enter the following:

    A

    B

    1

    name

    age

    2

    Cammy

    32

    3

    Josephine

    41

    4

    Ammie

    22

  4. Click Save Component.

Configure the Data Workflow Component

With the Data Table component set up, use the Create Field operator to add two key/value pairs to each row.

  1. Drag and drop a Data Workflow component onto your canvas, placing it  below your dtTable Data Table component.

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

Configure the Input Operator

Begin by connecting your Data Table to the Data Workflow using an Input operator.

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

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

Info

Category

Input

Component

dtTable

Required

Yes

Source

Default

Configure the Create Field Operator

Next, set up the Create Field operator and add two key/value pairs to each row (object) of your table (array).

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

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

    Info

    Category

    Create Field

    Label

    employment

    Do Not Sanitize Formula

    ☐ (unchecked)

    Preserve Argument Type

    ☐ (unchecked)

    Field 1

    insured="yes"

    Field 2

    renewalYear=2023

    Field 3

    Field 4

    Field 5

  3. Connect the output port (right) of the dtTable Input operator to the input port (left) of the employment Create Field operator.

Configure the First Console Operator

This Console operator shows your data before adding your key/value pairs.

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

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

    Info

    Category

    Console

    Label

    Before Create Field

  3. Connect the output port (right) of the dtTable Input operator to the input port (left) of the Before Create Field Console operator.

Configure the Second Console Operator

This Console operator shows your data after adding your key/value pairs.

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

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

    Info

    Category

    Console

    Label

    After Create Field

  3. Connect the output port (right) of the employment Create Field operator to the input port (left) of the After Create Field Console operator.

  4. Click Save Component.

Here's how the completed Data Workflow looks:

Configure the Button Component

Lastly, add a Button to trigger your Data Workflow.

  1. Drag and drop a Button component onto your canvas, placing it below your dwfCreateField Data Workflow.

  2. In the Property ID field, enter btnRunDWF.

  3. In the Label Text field, enter Run Create Field.

  4. Navigate to the Actions settings.

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

  6. In the On Click field, enter dwfCreateField.

  7. Click Save Component.

  8. Save your module.

Your completed module looks like the following:

Preview your module in Express View. Open the DevTools Console and click Run Create Field to view what displays in the DevTools Console:

The Create Field operator is a multi-purpose function that creates fields. Creators can also use the Create Field operator to:

  • Dynamically add key/value pairs based on your end-user's input.

  • Add key/value pairs with values based on the value of another field. For example, creating a field with a value calculated using the value from another field.

  • Add key/value pairs with a conditional value. For example, adding one of two possible values based on a conditional if/then expression.

  • Update existing fields in a Data Table component.

You'll find the Create Field operator in the Table group to the left of the Data Workflow canvas.

About the Info Window

Learn more about each setting in the Create Field operator's Info window:

Setting

Description

Category

Grayed out and non-adjustable setting indicating the operation type.

Label

Sets the label for your operator, displaying below the operator on your Data Workflow canvas.

This field is optional, but set a label if you use more than one of the same operator type. A label helps you identify your operators without opening any Info windows.

Do Not Sanitize Formula

When this checkbox is clear, the operator cleans values coming into or defined in the operator. For example, removing special characters. Some of those special characters include ', $, #, and &amp. The operator also cleans up complex values. For example, logically breaking up strings of numbers and letters using underscores. A sample module ID can go from 5f6b4cdfabf886024d4de2d3 to 5f_6b_4cdfabf_886024d_4de_2d_3.

Sanitizing improves performance. But it can also lead to unexpected data behavior. If your Create Field is not behaving as expected, try selecting this box. When selected, the operator uses your values and expressions as-is. This is best when working with complex values or values that should remain unchanged.

By default, this setting is selected, which means the operator does not attempt to sanitize.

Preserve Argument Type

When selected, this setting ensures the argument data type is respected when the operator executes.

Field 1-5

The Create Field operator has five different field options, letting Creators add multiple fields using a single operator.

Define the field you want to create or update, using the following format: key=value. For string values, add single or double quotes around the value. For example, employed="yes".

The value part of the key=value expression can also include calculations, conditional expressions, and references to other fields. It can also reference values coming into the argument port, using the alias _arg. For example, this expression that uses a calculation: incomeMonthly=_arg/12. The calculation happens on the input coming into the operator's argument port.

Or this one, that includes a conditional expression, a reference to another field, and a calculation:lowIncome=IF(incomeAnnual<24000,"yes","no"). Conditional expressions should use the following format: key=IF(condition,valueIfTrue,valueIfFalse).

How your data iterates through your Data Workflow depends on the type of key/value pairs you enter in these fields. This iteration order depends on the keys used:

  • Positive integer-like keys are displayed in ascending order.

  • String keys are displayed in insertion order.

  • Symbol keys are displayed in insertion order.

To learn more, view the ECMAScript language here: https://tc39.es/ecma262/#sec-ordinaryownpropertykeys.

Adding a Create Field Operator

In this example, you'll see how to add the same key/value pairs to every row in a table.

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

Configure the Data Table Component

First, add a Data Table to contain your key/value pairs.

  1. Drag and drop a Data Table component onto your canvas.

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

  3. In the data table, enter the following:

    #

    A

    B

    1

    name

    age

    2

    Cammy

    32

    3

    Josephine

    41

    4

    Ammie

    22

  4. Click Save & Close.

Configure the Data Workflow Component

With the Data Table component set up, use the Create Field operator to add two key/value pairs to each row.

  1. Drag and drop a Data Workflow component onto your canvas, placing it  below your dtTable Data Table component.

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

Configure the Input Operator

Begin by connecting your Data Table to the Data Workflow using an 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

    dtTable

    Required

    Yes

    Source

    Default

Configure the Create Field Operator

Next, set up the Create Field operator and add two key/value pairs to each row (object) of your table (array).

  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

    Create Field

    Label

    employment

    Do Not Sanitize Formula

    Unchecked (no)

    Preserve Argument Type

    Unchecked (no)

    Field 1

    insured="yes"

    Field 2

    renewalYear=2023

  3. Connect the output port (right) of the dtTable Input operator to the input port (left) of the employment Create Field operator.

Configure the First Console Operator

This Console operator shows your data before adding your key/value pairs.

  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

    Before Create Field

  3. Connect the output port (right) of the dtTable Input operator to the input port (left) of this first Before Create Field Console operator.

Configure the Second Console Operator

This Console operator shows your data after adding your key/value pairs.

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

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

    Setting

    Value

    Category

    Console

    Label

    After Create Field

  3. Connect the output port (right) of the employment Create Field operator to the input port (left) of the After Create Field Console operator.

  4. Click Save.

Configure the Button Component

Lastly, add a Button to trigger your Data Workflow.

  1. Drag and drop a Button component onto your canvas, placing it below your dwfCreateField Data Workflow.

  2. In the Property ID field, enter btnRunDWF.

  3. In the Label Text field, enter Run Create Field.

  4. Set the Action Type to Event.

  5. In the On Click field, enter dwfCreateField.

  6. Click Save & Close.

  7. Save your module.

Here's how the completed example looks in the Module Builder:

Preview your module in Express View and open the DevTools Console. Click Run Create Field to view what displays in the DevTools Console:

Resources