How to do calculations when using comma for decimal notation?
AnsweredHello we are experience a problem with the decimal numbers in a sublist.
We intend to introduce the details of an order using a sublist.
The sublist in supposed calculate the total price of the items, taxes, discount, etc. based on the number of items and the price for each item.
Everything woks until we use decimal numbers, for example for the price of an item. Then the results comes without decimal and multiplied by 100. An example.

PrecioUnitario = 10,5
Unidades = 99
PrecioBruto = PrecioUnitario * Unidades = should be 103,95 But instead it returns 10395
The server is in Spain so we are using comma for decimals and dots for thousands.
The regional configuration of the site correctly set for Spain and is working fine for the rest of the site.
Of course we need to use decimal numbers.
How can resolve this?
-
Hello Fernando,
We advise to make the following steps:
1. Open form in Design mode
2. Go to Behaviour tab, and click on Edit Button in Form Load Actions Group
3. Click Add Action and select "Execute Script" for property Type
Insert next code into an editor:
var numberFormat = Sys.CultureInfo.CurrentCulture.numberFormat;
var setFakeSeparators = function(){
numberFormat.CurrencyGroupSeparator = "FakeGroupSeparator";
numberFormat.CurrencyDecimalSeparator = "FakeDecimalSeparator";
};
setFakeSeparators();if(!Number.originalParseLocale){
Number.originalParseLocale = Number.parseLocale;
Number.parseLocale = function(value){
numberFormat.CurrencyGroupSeparator = ".";
numberFormat.CurrencyDecimalSeparator = ",";
var result = Number.originalParseLocale(value);
setFakeSeparators();
return result;
}
}
4.Click save.
5. Then user should modify his expression. He need to open Expression Builder for his cell or field.
6. Set Expression type to Function Code
and modify his expression like follow:
var result = <some calculation logic>;
return result.toString().replace(".", ",");
where instead of <some calculation logic> should be his expression
e.g video http://take.ms/murRr
Note: This works only for locales where decimal separator is "," and group separator "."
e.g. spain, danish
If you change to regional setting e.g. to English it will work wrong.Hope these steps help you.
Thank you
Best Regards
Rosario Matos
0 -
Hi Fernando,
the latest version has a bugfix for this problem.
Get it from here: /hc/en-us/articles/360012061120-skybow-Rich-Forms-Version-3-1-0-2
0
Please sign in to leave a comment.
Comments
2 comments