Convert Field Operator: Cast to String

Overview

The Convert Field operator includes an option to convert your data to an String data type. Let's say you have a data set with account information. For data processing purposes, you want your Account Value data to be in the string data type. This lets your data hold alphanumeric characters. To perform this conversion, you'll use a Convert Field operator.

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

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

What You'll Learn

In this article, you'll learn how to use the Convert Field operator's Cast to String setting.

What You'll Need

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

  • 1 Data Table component

  • 1 Button component

  • 1 Data Workflow component

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

  • 1 Input operator

  • 1 Convert Field operator

  • 2 Console operators

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

Configuration

Configure the Data Table Component

First, let's set up your account data. You'll use a Data Table component for that.

1. In the Module Builder, drag and drop a Data Table component onto your canvas.
2. Enter dtAccounts in the Label and Property Name fields.
3. In the data table, enter the following:
firstName certification accountValue

Blair

aws solutions architect

$1000000

JJ

 

$6789.00

Jim

 

1000000

Evan

aws developer

null

Charlotte

aws security

5000000

Amy

aws database

$5439294

Brian

aws machine learning

$178.90

Rupert

null

195.78

Emily

aws networking specialty

nine hundred thousand

4. Click Save.

Configure the Data Workflow Component

Next, let's set up your Data Workflow. You'll use an Input operator to bring in your data. Then, you'll use a Convert Field operator with the Cast To field set to String. You'll also include 2 Console operators so you can see what your data looks like before and after the conversion.

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

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

dtAccounts

Required

Yes

Source

Default

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

Before

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

Configure the Convert Field Operator

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

Setting

Value

Category

Convert To

Label

Convert accountValue to String

Cast To

String

Keys

accountValue

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

After

3. Connect the output port (right) of the Convert Field operator to the input port (left) of the After Console operator.
4. Click Save.

Configure the Button Component

Now, let's add a Button component to trigger the whole operation.

1. Drag and drop a Button component onto your canvas. Place your Button below your Data Workflow.
2. Enter btnConvert in the Property ID field.
3. Enter Convert to String in the Label field.
4. Select Event as the Action Type.
5. Enter dwfConvertFieldString in the Trigger on Click field.

6. Click Save.
7. Save your module.

Now you're ready to check your work. Preview your module in Express View and open the DevTools Console. Now, click your Convert to String button. You'll see your data both before and after the conversion. Notice that number values in your Before data show as blue. In your After data, everything shows as red. This indicates everything is stored as a string.

Lab

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