How to: Convert a Number to a String

Prev Next

Use the Convert Value operator 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 strings. The easiest way to tell if your number converted to a string is the quotation marks around your output. You'll set up a Number component for this example and enter and submit a number in Express View.

Before you begin, consider the following when converting numbers to strings:

  • Decimal points in your number also appear in your string output.

  • Numbers with commas display as text to the Number component, and the component does not accept them. An example would be 1,000,000.

  • Succeeding zeros in your number disappear after the conversion. For instance, the number 125.500 converts to the string "125.5".

Configuration

Configuring the Convert Value operator involves selecting the appropriate conversion type, defining input and output values, and specifying any additional transformation logic, depending on the data type being handled. This operator is essential for maintaining smooth data flow and ensuring that data is correctly formatted for various use cases in the Unqork platform.

Configure the Number Component

First, you'll set up a Number component so your end-user can enter a number to convert to a string.

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

  2. In the Property ID field, enter numberInput.

  3. In the Label Text field, enter Number 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's output.

  1. Drag and a Hidden component onto your canvas, placing it below your numberInput Number component.

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

  3. Click Save Component.

Configure the Data Workflow Component

Now, it's time to set up your Data Workflow. First, you'll input your Number component into a Convert Value operator. Then you'll cast any number entered in the Number component field to a string. This new string then outputs to your Hidden component. To watch your Data Workflow's progress, you'll also configure two Console operators.

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

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

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

    numberInput

    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 to String

    Cast To

    String

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

    stringOutput

    Action

    value

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

    Number Input

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

    String Output

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

  4. Click Save Component.

    Workflow diagram illustrating data conversion from input to string output in console.

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 your Data Workflow.

  2. In the Property ID field, enter btnConvertToString.

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

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

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

  6. Click Save.  

    Button configuration for converting numbers to strings with event triggers displayed.

  7. Save your module.

This is how the completed configuration looks in the Module Builder:

Input field for number conversion with output display and conversion button.

Preview your module in Express View. Enter a number, like 325.50, into the Number Input field and click the Convert Number to String button. The Number Input Console displays your number as you entered it. After passing through the Convert Value operator, the String Output Console displays the converted string. You'll see that the operator added quotation marks around your string "325.5".

Use the Convert Value operator 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 strings. The easiest way to tell if your number converted to a string is the quotation marks around your output. You'll set up a Number component for this example and enter and submit a number in Express View.

Before you begin, consider the following when converting numbers to strings:

  • Decimal points in your number also appear in your string output.

  • Numbers with commas display as text to the Number component, and the component does not accept them. An example would be 1,000,000.

  • Succeeding zeros in your number disappear after the conversion. For instance, the number 125.500 converts to the string "125.5".

Configuration

Configuring the Convert Value operator involves selecting the appropriate conversion type, defining input and output values, and specifying any additional transformation logic, depending on the data type being handled. This operator is essential for maintaining smooth data flow and ensuring that data is correctly formatted for various use cases in the Unqork platform.

Configure the Number Component

First, you'll set up a Number component so your end-user can enter a number to convert to a string.

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

  2. In the Property ID field, enter numberInput.

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

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

  5. Click Save.

Configure the Hidden Component

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

  1. Drag and a Hidden component onto your canvas, placing it below your numberInput Number component.

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

  3. Click Save.

Configure the Data Workflow Component

Now, it's time to set up your Data Workflow. First, you'll input your Number component into a Convert Value operator. Then you'll cast any number entered in the Number component field to a string. This new string then outputs to your Hidden component. To watch your Data Workflow's progress, you'll also configure two Console operators.

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

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

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

    numberInput

    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 to String

    Cast To

    String

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

    stringOutput

    Action

    value

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

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

    Number Input

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

    String Output

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

  4. Click Save.

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 your Data Workflow.

  2. In the Property ID field, enter btnConvertToString.

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

  4. Set the Action Type as Event.

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

  6. Click Save.  

  7. Save your module.

The completed configuration looks like the following in the Module Builder:

Input field for entering a number and converting it to a string output.

Preview your module in Express View. Enter a number, like 325.50, into the Number Input field and click the Convert Number to String button. The Number Input Console displays your number as you entered it. After passing through the Convert Value operator, the String Output Console displays the converted string. You'll see that the operator added quotation marks around your string "325.5".