How to: Omit Null Values Using the Clean Object Operator

Prev Next

The Clean Object operator can be used to streamline data by removing any properties (or fields) that contain a null value from an object. This operation is useful when you want to clean up data before passing it to another part of your application or system. By using this operator, you can ensure that objects do not include unnecessary null values, which could cause issues when processing or storing data.

Configuration

In this how-to guide, you'll create a data table that stores some sample data. You'll also add a Data Workflow component to create null values and another to test the omit function.

Configure the Data Table Component

First, you'll set up a Data Table component that includes a value with a company name.

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

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

  3. In the data table, enter the following:

    #

    value

    company

    1

    12

    Unqork

    2

    34

    Cvent

    3

    56

    Trustpilot

    4

    78

    BetterWorks

    5

    90

    J.P. Morgan

    Data table displaying values and corresponding company names for analysis.

  4. Click Save Component.

Configure the Hidden Components

Next, add two Hidden components to store the outputs of each Data Workflow component.

  1. Drag and drop two Hidden components onto your canvas, placing them below your dtSampleData Data Table component.

  2. Enter the following Property ID and Label Text values:

    Property ID

    Label Text

    dataWithNullValues

    dataWithNullValues

    dataWithoutNulls

    dataWithoutNulls

  3. Click Save Component as you add each component.

Configure the First Data Workflow Component

This Data Workflow component creates the null values you'll convert with the Clean Object operator.

  1. Drag and drop a Data Workflow component onto your canvas, placing it between the dtSampleData Data Table and dataWithNullValues Hidden components.

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

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

    dtSampleData

    Required

    Yes

    Source

    Default

Configure the Create Field Operator

You’ll configure a Create Field operator to add an extra value to the data. Each object includes a testField with the value of null.

  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

    Create Test Field

    Do Not Sanitize Formula

    (checked)

    Field 1

    testField=NULL

    Field 2

    Field 3

    Field 4

    Field 5

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

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

    dataWithoutNulls

    Action

    value

  3. Connect the output port (right) of the Create Test Field Create Field operator to the input port (left) of the dataWithoutNulls Output operator.

    Workflow diagram showing input, create field, and output processes for data handling.

  4. Click Save Component.

Configure the Second Data Workflow Component

  1. Drag and drop another Data Workflow component onto your canvas, placing it between the dataWithNullValues and dataWithoutNulls Hidden components.

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

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

    dataWithNullValues

    Required

    Yes

    Source

    Default

Configure the Clean Object Operator

This operator removes all the values from the null values from the dataWithNullValues Hidden component.

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

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

    Setting

    Value

    Category

    Clean Object

    Label

    Omit Null

    Clean Action

    Omit Null

  3. Connect the output port (right) of the dataWithNullValues Input operator to the input port (left) of the Omit Null Clean Object operator.

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

    nullToEmptyString

    Action

    value

  3. Connect the output port (right) of the Omit Null Clean Object operator to the input port (left) of the nullToEmptyString Output operator.

    Workflow diagram showing data input, cleaning, and output processes for omitting null values.

  4. Click Save Component.

  5. Save your module.

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

Data structure showing sample data with null and non-null values highlighted.

Preview your module in Express View and open the DevTools Console. You'll see the null value in testField has been omitted from the data.

Console output showing user data and submission details in a web application.

The Clean Object operator can be used to streamline data by removing any properties (or fields) that contain a null value from an object. This operation is useful when you want to clean up data before passing it to another part of your application or system. By using this operator, you can ensure that objects do not include unnecessary null values, which could cause issues when processing or storing data.

Configuration

In this how-to guide, you'll create a data table that stores some sample data. You'll also add a Data Workflow component to create null values and another to test the omit function.

Configure the Data Table Component

First, you'll set up a Data Table component that includes a value with a company name.

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

  2. In the Label and Property Name fields, enter dtSampleData.

  3. In the data table, enter the following:

    #

    value

    company

    1

    12

    Unqork

    2

    34

    Cvent

    3

    56

    Trustpilot

    4

    78

    BetterWorks

    5

    90

    J.P. Morgan

    Data table displaying company names and corresponding values for analysis.

  4. Click Save.

Configure the Hidden Components

Next, add two Hidden components to store the outputs of each Data Workflow component.

  1. Drag and drop two Hidden components onto your canvas, placing them below your dtSampleData Data Table component.

  2. Enter the following Property ID and Canvas Label Text values:

    Property ID

    Canvas Label Text

    dataWithNullValues

    dataWithNullValues

    dataWithoutNulls

    dataWithoutNulls

  3. Save & Close each component as you add it.

Configure the First Data Workflow Component

This Data Workflow component creates the null values you'll convert with the Clean Object operator.

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

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

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

    dtSampleData

    Required

    Yes

    Source

    Default

Configure the Create Field Operator

You’ll configure a Create Field operator to add an extra value to the data. Each object includes a testField with the value of null.

  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

    Create Test Field

    Do Not Sanitize Formula

    (checked)

    Field 1

    testField=NULL

    Field 2

    Field 3

    Field 4

    Field 5

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

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

    dataWithoutNulls

    Action

    value

  3. Connect the output port (right) of the Create Test Field Create Value operator to the input port (left) of the dataWithoutNulls Output operator.

    Data workflow diagram showing input, create field, and output processes for null values.

  4. Click Save.

Configure the Second Data Workflow Component

  1. Drag and drop another Data Workflow component onto your canvas.

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

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

    dataWithNullValues

    Required

    Yes

    Source

    Default

Configure the Clean Object Operator

This operator removes all the values from the null values from the dataWithNullValues Hidden component.

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

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

    Setting

    Value

    Category

    Clean Object

    Label

    Omit Null

    Clean Action

    Omit Null

  3. Connect the output port (right) of the dataWithNullValues Input operator to the input port (left) of the Omit Null Clean Object operator.

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

    nullToEmptyString

    Action

    value

  3. Connect the output port (right) of the Omit Null Clean Object operator to the input port (left) of the nullToEmptyString Output operator.

    Data workflow diagram showing input, clean object, and output processes for data management.

  4. Click Save.

  5. Save your module.

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

Data table showing sample data with null and non-null values for analysis.

Preview your module in Express View and open the DevTools Console. You'll see the null value in testField has been omitted from the data.

Console output showing user data and submission details in a web application.