Convert String (Full UTF-8) display value to currency Format?
This content was last updated in 2020. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2020 12:08 AM
Hi Community,
I have a requirement to convert String (Full UTF-8) field values to currency value .
eg : Commission Amount = 10000000
Expected: 10,000,000
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2020 02:36 AM
Yes in that case also you can do use this. Try putting it on change of your commission amount and use the same script.
If it does not work, please share your script once.
Thanks,
Mohit Kaushik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2020 04:02 AM
Hi Mohit,
code is executing till end but value is not getting set. Kindly look at the code
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
alert('code start here');
var usd = g_form.getValue('u_usd');
var curr = usd.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
alert('usd' + 'calculating');
function addCommas(usd){
usd+= '';
var x = usd.split('.');
var x1 = x[0];
var x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
alert('calculation done');
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
var curr =addCommas(usd);
alert('value set');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2020 05:39 AM
Hi Rafmine,
In which field you want to set the value, suppose it is 'abc' . Then just use this much part of code to achieve this:
//alert('code start here');
var usd = g_form.getValue('u_usd'); //here 'u_usd' is your original value field.
var curr = usd.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); // value calculation
g_form.setValue('abc',curr); //this will set the comma separated value into 'abc' field.
Thanks,
Mohit Kaushik