
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2016 07:47 AM
In a client script, I'm using g_form.addOption to populate a choice list dependent on another choice chosen on the form. My problem is I want to format the choices to make them more easily readable. The choices are coming from a table and are formatted as long. They're showing without commas making it very difficult to read. See below
I've seen that you can change the attributes of a field to format=none to exclude commas but how would I format the list to include them.
Here's the code:
var limit = new GlideRecord('u_ap_doa_expense_type_limits');
limit.addQuery('u_exp_type_id',exp.u_exp_type_id);
limit.orderBy('u_exp_type_limit');
limit.query();
while(limit.next()) {
var limitamt=parseInt(limit.u_exp_type_limit);
g_form.addOption('u_auth_lim', limitamt, limitamt);
}
Any help is much appreciated!!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2016 07:54 AM
Here's one method I found. Write yourself a little function that does a RegEx on a string representation and use that as the display value (third parameter.)
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2016 07:54 AM
Here's one method I found. Write yourself a little function that does a RegEx on a string representation and use that as the display value (third parameter.)
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2016 08:05 AM
Thank you!!! Worked perfectly