Automation Numerical Value Format Conversion
  • 1 Minute to read
  • Dark
    Light
  • PDF

Automation Numerical Value Format Conversion

  • Dark
    Light
  • PDF

Article Summary

When working with different currencies and data sets, it is recommended that you use the Execute code command with JavaScript to format the values according to your needs.

Here is an example of working with European currency. In most European countries, a comma is used as the decimal separator, for example, 679,00 EUR, whereas a decimal point (period) is used in other countries.

Panaya Data Sets work with integer parameters for numerical values. Below is the default format used -

###,###.###


To convert a supported data set input parameter from 679.00 to 679,00 follow the instructions in this article.

Converting the Format

  1. To convert, use an Execute code command -

  1. In the script, create a new input parameter - dataprice.


Then, set an internal parameter to a string value. We will later assign the formatted data price from the Data Set input parameter to this internal parameter.


3. In the Execute code screen, add the below JavaScript to format the price -

let num = panayaVars.dataprice; //assign the dataprice value to a variable num
var mystring = num.toString();  //convert the data set number value to a string
mystring = mystring.replace(/[,.]/g, function (m) {// If , is matched, return ., if . is matched, return , 
return m === ',' ? '.' : ','; }); (use JavaScript to format the string, and replace the "." with a "," where required)
panayaVars.price = mystring;  //update the price parameter back with the formatted price


  1. Set the Execute code command with the JavaScript in step 3 like shown below.


  2. Set the validate screen element command as the last instruction.