Convert Value Operator

Prev Next

Settings panel displaying options for converting values and preserving argument types.The Convert Value operator lets you take a specific key from a data set and convert the value to a number, integer, or string. Let's review these three data types:

  • Number: This data type is only for numbers. To be clear, we wouldn't classify the word ten as a number, but we would classify the number 10 as a number. This data type also allows for the use of decimals to differentiate it from an integer data type. When converting to a number data type, any original values with non-numeric characters will display as NaN (Not a Number) in your final data. To avoid lost data, ensure that your original data does not contain non-numeric characters.

  • Integer: This data type is also for numbers, but it does not allow for decimals. When converting to an integer, a number will only include the number before the decimal. When converting to an Integer data type, any original values with non-numeric characters display 0 in your final data. To avoid lost data, ensure that your original data does not contain non-numeric characters.

  • String: You'll sometimes see strings referred to as text. But this doesn't mean strings can only contain letters. Data stored as a string can include numbers, letters, symbols, and spaces. Strings can be as short as a few letters or contain entire paragraphs.

The Unqork Designer Platform handles each data type differently. And sometimes you'll need to convert the data collected from one data type to another.

You'll find the Convert Value operator under the Value/String group to the left of the Data Workflow canvas.

Similar Data Workflow Operators

The Convert Value operator is similar to the Convert Field operator. Here are the operators compared:

  • Convert Value operator: Converts a single value passed to it. It’s best used if you're only working with a single key/value pair of data.

  • Convert Field operator: Converts all values in a specified key of a data set. It’s best used if you're working with large amounts of data that need conversion.

About the Info Window

Here's a breakdown of each setting in the Info window:

Setting

Description

Category

Grayed out and non-adjustable setting indicating the operation type.

Label

Sets the label for your operator, displaying below the operator on your Data Workflow canvas.

This field is optional, but set a label if you use more than one of the same operator type. A label helps you identify your operators without opening any Info windows.

Cast To

The final data type you want after the operator performs its conversion. Here, you'll find a drop-down with the following options:

  • Number

  • Integer

  • String

Adding a Convert Value Operator

In this example, you'll learn how to convert a string into a number using the Convert Value operator. You'll use a Text Field component to ensure that any value you enter will be stored as a string. You'll enter a value in this field in Express View and trigger the Data Workflow with a button. On button-click, the Convert Value operator will convert the string into a number.

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

Configure the Text Field Component

First, you'll set up a Text Field component so your end-user can enter a string to convert. Remember, anything stored in a Text Field component is automatically a string.

  1. In the Module Builder, drag and drop a Text Field component onto your canvas.

  2. In the Property ID field, enter stringInput.

  3. In the Label Text field, enter String Input.

  4. In the Helper Text field, enter Enter a Number.

  5. Click Save Component.

Configure the Hidden Component

Next, you'll configure a Hidden component to store your Data Workflow component’s output.

  1. Drag and drop a Hidden component onto your canvas, placing it below your stringInput Text Field component.

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

  3. Click Save Component.

Configure the Data Workflow Component

Now, it's time to set up your Data Workflow component. First, you'll input your Text Field component  into a Convert Value operator. Then, you'll cast any string entered into the Text Field component as a number and output it into your Hidden component. To help you view the progress of your Data Workflow component, you'll configure two Console operators.

  1. Drag and drop a Data Workflow component onto your canvas, placing it below your numberOutput Hidden component.

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

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

    stringInput

    Required

    No

    Source

    Default

Configure the Convert Value Operator

  1. Drag and drop a Convert Value operator onto your Data Workflow canvas.

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

    Setting

    Value

    Category

    Convert To Value

    Label

    Convert String to Number

    Cast To

    Number

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

    numberOutput

    Action

    value

  3. Connect the output port (right) of the Convert String to Number Convert Value operator to the input port (left) of the numberOutput Output operator.

Configure the First Console Operator

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

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

    Setting

    Value

    Category

    Console

    Label

    String Input

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

Configure the Second Console Operator

  1. Drag and drop another Console operator onto your Data Workflow canvas.

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

    Setting

    Value

    Category

    Console

    Label

    Number Output

  3. Connect the output port (right) of the Convert String to Number Convert Value operator to the input port (left) of the Number Output Console operator.

  4. Click Save Component.

    A static image of a workflow illustrating data conversion from string to number with input and output.

Configure the Button Component

Now, let's add a Button component to trigger your Data Workflow.

  1. Drag and drop a Button component onto your canvas, placing it below the Data Workflow component.

  2. In the Property ID field, enter btnConvertToNumber.

  3. In the Label Text field, enter Convert String to Number.

  4. From the Action Type drop-down, select Event.

  5. In the Trigger on Click field, enter dwfConvertValueNumber.

    A Static image of a Button labeled 'Convert String to Number' with action triggers for user interaction.

  6. Click Save Component.

  7. Save your module.

Here's how the completed example looks in the Module Builder:

A staticimage of the final configuration for converting a string value to a Number

Preview your module in Express View and open the DevTools Console. Enter a number (with and without a decimal point) or text into your Text Field component and click the Convert String to Number button. Each submission will give you a stringInput and numberOutput Console output. Enter a number 500.50 into the field and click the button. Then, run the Angular command. When you expand your data, you'll see 500.50 as your input and 500.5  as your output. Quotation marks around your input show that it's a string. No quotation marks around your output means the conversion was successful.

A static image of the Interface showing options to convert values with fields for category, label, and cast.The Convert Value operator lets you take a specific key from a data set and convert the value to a number, integer, or string. Let's review these three data types:

  • Number: This data type is only for numbers. To be clear, we wouldn't classify the word ten as a number, but we would classify the number 10 as a number. This data type also allows for the use of decimals to differentiate it from an integer data type. When converting to a number data type, any original values with non-numeric characters will display as NaN (Not a Number) in your final data. To avoid lost data, ensure that your original data does not contain non-numeric characters.

  • Integer: This data type is also for numbers, but it does not allow for decimals. When converting to an integer, a number will only include the number before the decimal. When converting to an Integer data type, any original values with non-numeric characters display 0 in your final data. To avoid lost data, ensure that your original data does not contain non-numeric characters.

  • String: You'll sometimes see strings referred to as text. But this doesn't mean strings can only contain letters. Data stored as a string can include numbers, letters, symbols, and spaces. Strings can be as short as a few letters or contain entire paragraphs.

The Unqork Designer Platform handles each data type differently. And sometimes you'll need to convert the data collected from one data type to another.

You'll find the Convert Value operator under the Value/String group to the left of the Data Workflow canvas.

Similar Data Workflow Operators

The Convert Value operator is similar to the Convert Field operator. Here are the operators compared:

  • Convert Value operator: Converts a single value passed to it. It’s best used if you're only working with a single key/value pair of data.

  • Convert Field operator: Converts all values in a specified key of a data set. It’s best used if you're working with large amounts of data that need conversion.

About the Info Window

Here's a breakdown of each setting in the Info window:

Setting

Description

Category

Grayed out and non-adjustable setting indicating the operation type.

Label

Sets the label for your operator, displaying below the operator on your Data Workflow canvas.

This field is optional, but set a label if you use more than one of the same operator type. A label helps you identify your operators without opening any Info windows.

Cast To

The final data type you want after the operator performs its conversion. Here, you'll find a drop-down with the following options:

  • Number

  • Integer

  • String

Adding a Convert Value Operator

In this example, you'll learn how to convert a string into a number using the Convert Value operator. You'll use a Text Field component to ensure that any value you enter will be stored as a string. You'll enter a value in this field in Express View and trigger the Data Workflow with a button. On button-click, the Convert Value operator will convert the string into a number.

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

Configure the Text Field Component

First, you'll set up a Text Field component so your end-user can enter a string to convert. Remember, anything stored in a Text Field component is automatically a string.

  1. In the Module Builder, drag and drop a Text Field component onto your canvas.

  2. In the Property ID field, enter stringInput.

  3. In the Label Text field, enter String Input.

  4. In the Helper Text field, enter Enter a Number.

  5. Click Save & Close.

Configure the Hidden Component

Next, you'll configure a Hidden component to store your Data Workflow component's output.

  1. Drag and drop a Hidden component onto your canvas, placing it below your stringInput Text Field component.

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

  3. Click Save & Close.

Configure the Data Workflow Component

Now, it's time to set up your Data Workflow component. First, you'll input your Text Field component  into a Convert Value operator. Then, you'll cast any string entered into the Text Field component as a number and output it into your Hidden component. To help you view the progress of your Data Workflow component, you'll configure two Console operators.

  1. Drag and drop a Data Workflow component onto your canvas, placing it below your numberOutput Hidden component.

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

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

    stringInput

    Required

    No

    Source

    Default

Configure the Convert Value Operator

  1. Drag and drop a Convert Value operator onto your Data Workflow canvas.

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

    Setting

    Value

    Category

    Convert To Value

    Label

    Convert String to Number

    Cast To

    Number

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

    numberOutput

    Action

    value

  3. Connect the output port (right) of the Convert String to Number Convert Value operator to the input port (left) of the numberOutput Output operator.

Configure the First Console Operator

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

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

    Setting

    Value

    Category

    Console

    Label

    String Input

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

Configure the Second Console Operator

  1. Drag and drop another Console operator onto your Data Workflow canvas.

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

    Setting

    Value

    Category

    Console

    Label

    Number Output

  3. Connect the output port (right) of the Convert String to Number Convert Value operator to the input port (left) of the Number Output Console operator.

Configure the Button Component

Now, let's add a Button component to trigger your Data Workflow component.

  1. Drag and drop a Button component onto your canvas, placing it below your Data Workflow component.

  2. In the Property ID field, enter btnConvertToNumber.

  3. In the Label field, enter Convert String to Number.

  4. Set the Action Type as Event.

  5. In the Trigger on Click field, enter dwfConvertValueNumber.

    A static image of a button settings for a workflow module with action types and event ID fields.

  6. Click Save & Close.

  7. Save your module.

Here's how the completed example looks in the Module Builder:

A static image of a Module editor interface displaying string input and conversion button for number output.

Preview your module in Express View and open the DevTools Console. Enter a number (with and without a decimal point) or text into your Text Field component and click the Convert String to Number button. Each submission will give you a stringInput and numberOutput Console output. Enter a number 500.50 into the field and click the button. Then, run the Angular command. When you expand your data, you'll see 500.50 as your input and 500.5  as your output. Quotation marks around your input show that it's a string. No quotation marks around your output means the conversion was successful.

A static image of a console output showing string to number conversion examples and user details in Unqork.