Can we add comma's in between numbers in vDesigner

How to show or convert number into comma separated number in vDesigner?
Ex: 45678.96 Expected output: 45,678.96

3 Likes

There are various functions available in vDesigner. Below is the function to convert number with comma separated number.
Syntax: NUM_WITH_COMMAS(Path of value in JSON AOF.PAYMENT.AMOUNT, true)

NUM_WITH_COMMAS function as the name suggests is a function which adds commas to a number.
As of now it only adds commas in the format #,##,###.
In this function, two parameters are taken, first the number and second ‘allow decimal’, which is used to
determine whether there should be decimal value in the result after adding the commas or not.
Below is an example of the complete syntax for the NUM_WITH_COMMAS Function:-
NUM_WITH_COMMAS(number, allow decimal(true/false))
let the number be 123245.98
and allow decimal be true
below is the query representing the above parameters:-
NUM_WITH_COMMAS(123245.98, true)
Result:- 1,23,245.98
this function can be used in copy value and group copy as well. And the number can be fetched from json
path as well as from a control.
NOTE:- IF THE SECOND PARAMETER IS LEFT EMPTY THEN ITS DEFAULT VALUE IS PICKED
UP WHICH IS FALSE.

6 Likes

If the format is #,##,### how do we represent 1025000 which should read 10,25,000 (##,##,###)?

1 Like

This will be automatically managed by the system itself, The default structure is like (##,##,##,##,##,###).
For ex: IF the entered value is 123456789 then the output will be 12,34,56,789
So even if we increase the value it will automatically add comma’s like for value 1234567891234 the output will be 12,34,56,78,91,234

Hope this helps, let me know if your doubt is still not cleared.

5 Likes

This is good but number is sent to server as is with comma. This sometimes result is api failure.

The system should keep numbers as number and format at display level only.

4 Likes

Perfect. Thank you. I just wanted to be sure

1 Like

How does that work? If the data type is originally number does this function change it to string?

3 Likes

For this kind of approach the copy value task is used that means you can copy the number with comma’s to a different JSON path. In this way you can have the number and the string with comma’s both on different JSON path’s. User can show the value with comma but send the value without comma to server.

5 Likes

That seems to be as it should be. What do you think Vinay?

1 Like

@dinesh.parekh It will work but It is more of a workaround for me.

Typically, you would directly transform the number at runtime for display.

Copying data is an overhead that one would want to avoid.

2 Likes

Agreed, We can enhance that section where functions can be directly associated with Widgets/Elements.

4 Likes