Clean Object Operator: Set Null to Empty String

Prev Next

Overview

One of the Clean Object operator's actions types is Set Null to Empty String. This action type converts all null values to empty strings. The empty strings look like "". The action also cleans up the entirety of the data object, including any nested objects.

For this use case, you'll first create a Data Table that holds some values. You'll also add a Data Workflow component whose sole purpose is to create null values. This will let you actually test the Set Null to Empty action.

Here's how your module will look in the Module Builder:

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

What You'll Learn

In this article, you'll learn how to use the Clean Object operator's Set Null to Empty String action type.

What You'll Need

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

  • 1 Data Table component

  • 2 Hidden components

  • 2 Data Workflow components

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

  • 1 Input operator

  • 1 Clean Object operators

  • 1 Output operator

Configuration

Configure the Data Table Component

First, you'll set up a Data Table with a company and its value.

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

  2. Enter dtSampleData in the Label and Property Name fields.

  3. In the data table, enter the following:

    value

    company

    12

    Unqork

    34

    Cvent

    56

    Trustpilot

    78

    BetterWorks

    90

    J.P. Morgan

  4. Click Save.

Configure the Hidden Components

Before you can add your Data Workflows, you'll need places to store the outputs. You'll use 2 Hidden components, one for each Data Workflow.

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

  2. Enter the following Property IDs and Canvas Label Text:

    Property ID

    Canvas Label Text

    dataWithNullValues

    dataWithNullValues

    nullToEmptyString

    nullToEmptyString

  3. Save each component as you add it.

Configure the First Data Workflow Component

This Data Workflow component just 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 below your Hidden components.

  2. Enter dwfCreateNullValues in the Canvas Label Text and Property Name fields.

Configure the Input Data Operator

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

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

    Setting

    Value

    Category

    Input

    Component

    dtSampleData

    Required

    Yes

    Source

    Default

Configure the Create Field Operator

This operator is going to add an extra value to the data. Now, 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 Create Field operator's Info window as follows:

    Setting

    Value

    Category

    Formula

    Label

    Create Test Field

    Do Not Sanitize Formula

    Checked (Yes)

    Field 1

    testField=NULL

    Field 2

    Field 3

    Field 4

    Field 5

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

Configure the Output Operator

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

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

    Setting

    Value

    Category

    Output

    Component

    dataWithNullValues

    Action

    value

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

  4. Click Save.

Configure the Second Data Workflow Component

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

  2. Enter dwfSetNullToEmpty in the Canvas Label Text and Property Name fields.

Configure the Input Data Operator

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

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

    Setting

    Value

    Category

    Input

    Component

    dataWithNullValues

    Required

    Yes

    Source

    Default

Configure the Clean Object Operator

This operator is going to convert all the values from the dataWithNullValues

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

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

    Setting

    Value

    Category

    Clean Object

    Label

    Set Null

    Clean Action

    Set Null to empty string

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

Configure the Output Operator

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

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

    Setting

    Value

    Category

    Output

    Component

    nullToEmptyString

    Action

    value

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

  4. Click Save.

  5. Save your module.

Now you can test your Data Workflow. Preview your module in Express View and then open the DevTools Console. You'll see the null value in testField is now a string.

Lab

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