Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Populating a currency field (through scripting) with a value based on another currency field using getDisplayValue() populates the field with 0.00 - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Populating a currency field (through scripting) with a value based on another currency field using getDisplayValue() populates the field with 0.00
KB0623630

Populating a currency field (through scripting) with a value based on another currency field using getDisplayValue() populates the field with 0.00


10968 Views Last updated : Oct 7, 2022 public Copy Permalink English (Original)
  • English (Original)
  • Japanese
KB Summary by Now Assist

Issue

Populating a currency field (through scripting) with a value based on another currency field using getDisplayValue() populates the field with 0.00

Problem

In Helsinki, when a currency field is updated through a script with the getDisplayValue of another currency field (so including the currency symbol in the string value, e.g., current.sysapproval.price.getDisplayValue();), the code accepts that and is able to strip off the currency symbol and populate the field with just the numeral part. In Istanbul and later, the same update does not work; the currency field is not updated or gets set to 0.00 if it had no value before.

Sample Case

The following case reproduces the behavior that was reported.

The table u_test_table has two similar currency fields:

  • money
  • u_amount3

The money field currently has the value 711.09 for the record with sys_id 29ee07db131cf200bc5bb9d12244b0b5.

  1. Run the following background script:

    var gr = new GlideRecord("u_test_table"); 
    gr.get('sys_id', '29ee07db131cf200bc5bb9d12244b0b5'); 
    gs.debug(' amount: '+ gr.money); 
    
    gr.u_amount3 = gr.money.getDisplayValue(); 
    // gr.u_amount3 = gr.money; 
    gr.update(); 
    gs.debug(' u_amount3: '+ gr.u_amount3); 
    
    --> that does not change the value for u_amount3
  2. Change the script so that it does not update the value with getDisplayValue but rather just with the gr.money value.

    It then works and updates the value. 

    Doing the same on a Helsinki instance, even with the provided code (with gr.money.getDisplayValue()), updates the u_amount3 field to the expected value 711.09.

Cause

The getDisplayValue() function returns the value of the currency field, formatted in standard currency formatting (with decimal and thousand separators) including the currency symbol. In Helsinki, that currency symbol gets stripped of its value when populating a field with this value. In versions beginning with Istanbul, this behavior no longer happens.

Resolution

In the script, do not use getDisplayValue() from a currency field to populate another currency field. Use, for example, current.price, or gr.money as in the example. From a coding perspective, there is no valid reason to populate a currency value with the display value of another currency field.

Related Links

For more information, see the product documentation topic Currency values in scripts.


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.