This is more of a javascript question. Does anyone have an easy way to convert a number like 1234567 to 1,234,567 format?
I tried using toLocaleString() but it doesn't seem to work. I then tried using a regex but couldn't make it work either. I then thought about adding commas to every third digit using for loop before I stopped myself and reached out for help.
Solved! Go to Solution.
Solved by leungjcp. Go to Solution.
There are a couple of ways of formatting numbers
You can use a computed field like this:
TO_CHAR(UGLY_FIELD, 'FM999,999,999,990D00')
Or
You can use script a a regular expression like this
item.NICE_FIELD = uglyField.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
I tried both of these and they seem to work.