The Convert Value operator is used to change a single data type into another. Data types include strings, integers, and numbers. In this article, you'll learn how to convert individual number values into integers.
Before you begin, there are a couple of considerations to make when converting numbers to integers:
If you enter a number with a decimal, the Convert Value operator removes it and every number to the right of it. For example, if you convert
12.345, the output is12.Numbers with commas display as text to the Number component, and it won't accept them. An example would be
1,000,000.
Configuration
In this how-to guide, you'll set up a Number component so an end-user can enter a number to be converted. Then, you’ll set up a Data Workflow component with a Convert Value operator to manipulate the value.
Configure the Number Component
First, you'll set up a Number component so your end-user can enter a number to convert to an integer.
In the Module Builder, drag and drop a Number component onto your canvas.
In the Property ID field, enter
numberInput.In the Label Text field, enter
Number Input.In the Helper Text field, enter
Enter a Number.Click Save Component.
Configure the Hidden Component
Next, you'll configure a Hidden component to store your Data Workflow's output.
Drag and a Hidden component onto your canvas, placing it below your
numberInputNumber component.In the Property ID and Label Text fields, enter
integerOutput.Click Save Component.
Configure the Data Workflow Component
Now, it's time to set up your Data Workflow. First, you'll bring your Number component data into the Data Workflow using an Input operator. Then, you’ll pass that data to the Convert Value operator and cast any number entered in the Number field to an integer. Then, output the new integer to your Hidden component. You'll also configure two Console operators to view the progress in the DevTools Console.
Drag and drop a Data Workflow component onto your canvas, placing it below your Hidden component.
In the Property ID and Canvas Label Text fields, enter
dwfConvertValueInteger.
Configure the Input Operator
Drag and drop an Input operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Input
Component
numberInput
Required
No
Source
Default
Configure the Convert Value Operator
Drag and drop a Convert Value operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Convert To Value
Label
Convert to Integer
Cast To
Integer
Connect the output port (right) of the
numberInputInput operator to the input port (left) of theConvert to IntegerConvert Value operator.
Configure the Output Operator
Drag and drop an Output operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Output
Component
integerOutput
Action
value
Connect the output port (right) of the
Convert to IntegerConvert Value operator to the input port (left) of theintegerOutputOutput operator.
Configure the First Console Operator
Drag and drop a Console operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Console
Label
Number Input
Connect the output port (right) of the
numberInputInput operator to the input port (left) of theNumber InputConsole operator.
Configure the Second Console Operator
Drag and drop another Console operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Console
Label
Integer Output
Connect the output port (right) of the
Convert to IntegerConvert Value operator to the input port (left) of theInteger OutputConsole operator..png)
Click Save Component.
Configure the Button Component
Lastly, let's add a Button component to trigger your Data Workflow.
Drag and drop a Button component onto your canvas, placing it below your
dwfConvertValueIntegerData Workflow.In the Property ID field, enter
btnConvertToInteger.In the Label Text field, enter
Convert Number to Integer.Set the Action Type drop-down, select
Event.Under Triggers, in the On Click drop-down, select
dwfConvertValueInteger..png)
Click Save.
Save your module.
Here's how your completed module looks in the Module Builder:
.png)
Preview your module in Express View and open the DevTools Console. Enter a number, like 250.25, into the Number field. Click the Convert Number to Integer button. The Number Input Console displays your number as you entered it. After passing through the Convert Value operator, the Integer Output Console displays the converted integer. You'll see that the operator removed the decimal point and the numbers to the right of it, leaving 250.
.jpg)
The Convert Value operator is used to change a single data type into another. Data types include strings, integers, and numbers. In this article, you'll learn how to convert individual number values into integers.
Before you begin, there are a couple of considerations to make when converting numbers to integers:
If you enter a number with a decimal, the Convert Value operator removes it and every number to the right of it. For example, if you convert
12.345, the output is12.Numbers with commas display as text to the Number component, and it won't accept them. An example would be
1,000,000.
Configuration
In this how-to guide, you'll set up a Number component so an end-user can enter a number to be converted. Then, you’ll set up a Data Workflow component with a Convert Value operator to manipulate the value.
Configure the Number Component
First, you'll set up a Number component so your end-user can enter a number to convert to an integer.
In the Module Builder, drag and drop a Number component onto your canvas.
In the Property ID field, enter
numberInput.In the Label Text field, enter
Number Input.In the Helper Text field, enter
Enter a Number.Click Save.
Configure the Hidden Component
Next, you'll configure a Hidden component to store your Data Workflow's output.
Drag and a Hidden component onto your canvas, placing it below your
numberInputNumber component.In the Property ID and Canvas Label Text fields, enter
integerOutput.Click Save.
Configure the Data Workflow Component
Now, it's time to set up your Data Workflow. First, you'll bring your Number component data into the Data Workflow using an Input operator. Then, you’ll pass that data to the Convert Value operator and cast any number entered in the Number field to an integer. Then, output the new integer to your Hidden component. You'll also configure two Console operators to view the progress in the DevTools Console.
Drag and drop a Data Workflow component onto your canvas, placing it below your Hidden component.
In the Canvas Label Text and Property Name fields, enter
dwfConvertValueInteger.
Configure the Input Operator
Drag and drop an Input operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Input
Component
numberInput
Required
No
Source
Default
Configure the Convert Value Operator
Drag and drop a Convert Value operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Convert To Value
Label
Convert to Integer
Cast To
Integer
Connect the output port (right) of the
numberInputInput operator to the input port (left) of theConvert to IntegerConvert Value operator.
Configure the Output Operator
Drag and drop an Output operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Output
Component
integerOutput
Action
value
Connect the output port (right) of the
Convert to IntegerConvert Value operator to the input port (left) of theintegerOutputOutput operator.
Configure the First Console Operator
Drag and drop a Console operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Console
Label
Number Input
Connect the output port (right) of the
numberInputInput operator to the input port (left) of theNumber InputConsole operator.
Configure the Second Console Operator
Drag and drop another Console operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Console
Label
Integer Output
Connect the output port (right) of the
Convert to IntegerConvert Value operator to the input port (left) of theInteger OutputConsole operator.
Click Save.
Configure the Button Component
Lastly, let's add a Button component to trigger your Data Workflow.
Drag and drop a Button component onto your canvas, placing it below your Data Workflow component.
In the Property ID field, enter
btnConvertToInteger.In the Label Text field, enter
Convert Number to Integer.Set Action Type as Event.
From the On Click drop-down, select dwfConvertValueInteger.
.png)
Click Save.
Save your module.
Here's how your completed module looks in the Module Builder:

Preview your module in Express View and open the DevTools Console. Enter a number, like 250.25, into the Number field. Click the Convert Number to Integer button. The Number Input Console displays your number as you entered it. After passing through the Convert Value operator, the Integer Output Console displays the converted integer. You'll see that the operator removed the decimal point and the numbers to the right of it, leaving 250.
.jpg)