currency type filed

eyal abu hamad
Mega Sage

Hey, I have currency type filed on project table.
when I get the value in business rule the value automatically converted to other currency.
its weird because I get the currency using 

current.u_additional_external_costs.getCurrencyCode()
and the currency is correct but the value is not.
why its doing that and how to fix ?
eyalabuhamad_0-1741683205651.png
eyalabuhamad_1-1741683218978.png

 

6 REPLIES 6

Tushar
Kilo Sage
Kilo Sage

Hi @eyal abu hamad 

 

I think System-stored values are always in the base currency—don’t rely on getValue() alone.

 

below can be use to get the formatted value in the correct currency rather than the system-stored conversion.

current.u_additional_external_costs.getDisplayValue();
gs.info("Currency Value: " + currencyValue);

 

Thanks,

Tushar

Hey, this is the gs.info that I use in the business rule

gs.info('eyal test project' + current.getDisplayValue('u_additional_external_costs') +'    and the currncy is = '+ current.u_additional_external_costs.getCurrencyCode() + ' regualr value is ' + current.u_additional_external_costs);

everything is returning the converted number

Hi @eyal abu hamad -

 

GlideCurrencyConverter.getAmountInCurrency(gr, 'field', 'currency_code')
This retrieves the amount in the actual currency instead of the automatically converted system base currency.

 

var gr = new GlideRecord('project'); // your table
if (gr.get(current.sys_id)) {
    var currencyField = 'u_additional_external_costs';
    var targetCurrency = gr.getValue('currency'); // get record's currency

    //get actual amount in the stored currency
    var convertedAmount = GlideCurrencyConverter.getAmountInCurrency(gr, currencyField, targetCurrency);

    gs.info('Eyal Test Project: Display Value = ' + gr.getDisplayValue(currencyField) + 
            ', Currency = ' + gr.getCurrencyCode(currencyField) + 
            ', Corrected Amount = ' + convertedAmount);
}

 

If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful." Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Ravi Gaurav
Giga Sage
Giga Sage

Hi @eyal abu hamad 
If you want to retrieve the exact value stored in the database without conversion, use the getDisplayValue() method, which gives the raw amount in the stored currency.

current.u_additional_external_costs.getCurrencyCode();

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/