Replacing symbols in the script rule in Vantage does not work properly for field type Number.


Replacing symbols in the script rule in Vantage does not work properly.

In skill, there is a column of Number data type:

There is an advanced script rule that replaces some trash symbols like slashes, spaces, etc. with an empty substring:

var field = Context.GetField("New Table/Withdrawal");
if (field != null)
var x = field.Text
if (x.length < 1)
   field.Value = 0.00
    x = x.replace(/,/g,'')

       field.Value = Number(x);

However, it does do anything. Symbols are not getting replaced.


This is caused by the way optimization of automatic data type casting works.

The Number is a primitive data type in JavaScript.

Vantage is able to automatically parse text values and convert them into numbers in fields. If to hover the instance of the field with the mouse pointer there will be a pop-up with a numeric value:

That means, despite the text representation containing a slash character, Vantage was able to cast it to the number and understand that the numeric representation is 30. The same happens to field instances containing commas and spaces:

When using:

field.Value = Number(x);

it sees that on the left was a primitive value 30 (as a result of auto-casting) and on the right is Number("30") -> giving the same 30. As the Number is a primitive data type, 30 on the left is the same for JavaScript as 30 on the right. For the sake of optimization, it just doesn't do anything i.e. doesn't do an assignment of a variable to the same primitive value. If to change the line to:

field.Value = Number(x) + 1;

the value on the left won't be equal to the value on the right and the assignment will take place.


To solve the issue, something like this can be written:

field.Value = null;
field.Value = Number(x);

Have more questions? Submit a request



Please sign in to leave a comment.