Overview
The Convert Field operator includes an option to convert your data to an Integer 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 integer data type. This cuts any numbers off at the decimal point. 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 Integer 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.
In the Module Builder, drag and drop a Data Table component onto your canvas.
Enter dtAccounts in the Label and Property Name fields.
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
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 Integer. You'll also include 2 Console operators so you can see what your data looks like before and after the conversion.
Drag and drop a Data Workflow component onto your canvas. Place your Data Workflow below your Data Table.
Enter dwfConvertFieldInteger in the Canvas Label Text and Property Name fields.
Configure the Input Operator
Drag and drop an Input operator onto your Data Workflow canvas.
Configure the Input operator's Info window as follows:
Setting
Value
Category
Input
Component
dtAccounts
Required
Yes
Source
Default
Configure the First Console Operator
Drag and drop a Console operator onto your Data Workflow canvas.
Configure the Console operator's Info window as follows:
Setting
Value
Category
Console
Label
Before
Connect the output port (right) of the Input operator to the input port (left) of the Console operator.
Configure the Convert Field Operator
Drag and drop a Convert Field operator onto your Data Workflow canvas.
Configure the Convert Field operator's Info window as follows:
Setting
Value
Category
Convert To
Label
Convert accountValue to Integer
Cast To
Integer
Keys
accountValue
Connect the output port (right) of the Input operator to the input port (left) of the Convert Field operator.
Configure the Second Console Operator
Drag and drop another Console operator onto your Data Workflow canvas.
Configure the Console operator's Info window as follows:
Setting
Value
Category
Console
Label
After
Connect the output port (right) of the Convert Field operator to the input port (left) of the After Console operator.
Click Save.
Configure the Button Component
Now, let's add a Button component to trigger the whole operation.
Drag and drop a Button component onto your canvas. Place your Button below your Data Workflow.
Enter btnConvert in the Property ID field.
Enter Convert to Integer in the Label field.
Select Event as the Action Type.
Enter dwfConvertFieldInteger in the Trigger on Click field.
Click Save.
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 Integer button. You'll see your data both before and after the conversion. Notice that each accountValue has been converted to an integer. If you see a 0, that's because the original data for that value included non-numerical characters.
Lab
You can view this complete use case here: https://training.unqork.io/#/form/6054d0264cf09403450f8f52/edit.