Get currency from glide record

Fabio Cresta
ServiceNow Employee
ServiceNow Employee

Hi All.

From an onLoad client script in a table I need to get the currency symbol from another table.

This is the script:

 

function onLoad() {
    var parentCurrency;
    var parentDemand = g_form.getValue("task");
    var grDemand = new GlideRecord("dmn_demand");
   
    grDemand.get(parentDemand);
    parentCurrency = grDemand.capital_outlay.getCurrencyCode();
alert(parentCurrency);
}
 
The problem is that grDemand.capital_outlay, that is an FXCurrency field, only returns the amount and not the whole currency.
Any help?
Thanks
1 REPLY 1

Maik Skoddow
Tera Patron
Tera Patron

Hi @Fabio Cresta 

never, really never perform GlideRecord operations in a client-side script!!!

Instead, perform the code in a display Business Rule, store the result in the g_scratchpad object and access the value via g_scratchpad in your client-script.

Maik