87 views

Description

Denmark Kroner Currency field saves the wrong value after calculation

Steps to Reproduce 

  1. Navigate to System Definition > Plugins.
  2. Search for and open the record for the Denmark Kroner Currency plugin.
  3. In Related Links, click Activate/Upgrade.
  4. Click Activate.
  5. Click View Plugin List.
  6. Navigate to System Properties > System Localization.
  7. Update the following fields:
    • In If using the single currency model, display all currencies using this currency code, specify DKK
    • In The value of this property determines the system's default currency into which all prices are automatically converted before other sums or conversions are performed, specify da.DK
  8. Click Save.
  9. Navigate to Incidents > Open.
  10. Open any incident record.
  11. Right-click in the header and select Configure > Form Layout.
  12. In Create new field, add a field:
    • In Name, type Currency (currency_test)
    • In Type, select Currency
  13. Click Add.
  14. Click Save.
  15. Click Close.
  16. Navigate to Incident > Create New.
  17. In the new Currency field, change the value from 0,00 to 1000,00.
  18. Click Submit.
  19. Open the incident you just created.
  20. Right-click in the header and select Copy sys_id.
  21. Copy the sys_id.
  22. Click OK.
  23. Paste the sys_id into this script:

    var m = new GlideRecord('incident');
    m.get('sys_id of the incident');
    //Get Currency-code and -value
    var curr = m.currency_test.getCurrencyCode();
    var currValue = m.currency_test.getCurrencyValue();
    //Make a calculation on the currency-value
    var calcValue = currValue/3;
    //Update the Model with the new value
    m.currency_test = curr + ";" + calcValue;
    gs.print(curr); gs.print(currValue);
    gs.print(calcValue); m.update();

  24. Navigate to System Definition > Scripts Background.
  25. Paste the script.
  26. Click Run.
    Output: *** Script: DKK *** Script: 1000 *** Script: 333.3333333333333
    Note that the currency_test field is now saved with value of 3.333.333.333.333.333,00. The currency_test field should be saved with value of 333,33.

Workaround

The value of a currency element can only be set to a number using code such as gr.currency_field = 10. Use the GlideElement setDisplayValue() method to set a currency type and value.


Related Problem: PRB656041

Seen In

Fuji Patch 7 Hot Fix 5

Fixed In

Istanbul

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2016-11-01 15:29:36
Published:2016-11-01