Notifications

183 views

Description

When creating a consumable asset, the system may return an incorrect cost value due to the locale decimal delimiter. The issue occurs on an instance configured to use multiple languages in System Properties > System Localization, for example with en_DE and fr_CH locales, not on an instance set with single language/currency.

Steps to Reproduce

1. Install the following plugins on a demo instance:
- I18N: Internationalization (com.glide.i18n)
- I18N: Knowledge Management Internationalization Plugin v2 (com.glideapp.knowledge.i18n2 installed when com.glide.i18n is activated)
- I18N: German Translations (com.snc.i18n.german).

2. Navigate to System Properties > Localizations (/nav_to.do?uri=%2Fsystem_properties_ui.do%3Fsysparm_category%3Di18n%26sysparm_title%3DSystem%2520Localization).

3. Ensure that the following is set to Yes:
- Show the language select box on the login page to allow the user to specify the language they would like to be logged in with.

4. Navigate to System Security > Users:
- Open the User record for David Loo: set 'Country code' field to Germany
- Open the User record for Fred Luddy : leave 'Country code' field as it is ( currently set to System GB)

5. Impersonate user David Loo.

6. Navigate to Product Catalog > Product Models > Consumable Models.

7. Open one of the Consumable Models, for example 'Acer Notebook Battery' (/nav_to.do?uri=cmdb_consumable_product_model.do?sys_id=26431e62ac10a501177f7cd98f0de15e).
Observe the cost is $89.99.

8. Navigate to Asset > Portfolios > Consumables.

9. Click New and enter the following field values:
Model category = Consumables
Model = Acer Notebook Battery (chosen in step 7).

Once the Model field is filled, observe the Cost field is populated with €79,8633.

10. Save the record (right click on the header > Save).
Observe the Cost field changed to €798,633.00.
(screenshot attached : DavidLoo_after_save)

11. Impersonate user Fred Luddy, whose country is set to GB.

12. Navigate to Product Catalog > Product Models > Consumable Models.

13. Open one of the Consumable Models, for example '3Com Cat 5 Cable (10ft)' (/nav_to.do?uri=cmdb_consumable_product_model.do?sys_id=c7928ec237732000158bbfc8bcbe5da9).
Observe the cost is $88.00.

14. Navigate to Asset > Portfolios > Consumables.

15. Click New and enter the following field values:
Model category = Consumables
Model = 3Com Cat 5 Cable (10ft) (chosen in step 13).

Once the Model field is filled, observe the Cost field is populated with £68.6865.

16. Save the record (right click on the header > Save).
Observe the Cost field does not change, it still has a value of £68.6865, as the locale delimiter is dot instead of comma.
(screenshot attached : FredLuddy_after_save)

Workaround

This problem is under review and targeted to be fixed in a future release. To receive notifications when more information becomes available, subscribe to this Known Error article by clicking the Subscribe button at the top right of this form.

The workaround consists in creating a Global UI Script ("SNC Workaround for PRB1326824") as listed below. This should be set in a dev instance and activated on a prod instance only after testing.

NOTE: THIS WORKAROUND OVERRIDES AN INTERNAL API AND NEEDS TO BE REMOVED WHEN UPGRADING TO A VERSION THAT ALREADY HAS THE FIX.

addTopRenderEvent(function() {
	if (typeof CurrencyElement !== "undefined") {
		CurrencyElement.prototype._extractCurrency = function(currency) {
			var currencyParts = currency.split(';');
			var localeCode = window.NOW.locale.code.replace(/_/g, '-');
			var currencyCode = currencyParts[0];
			var value = currencyParts[1].replace(/[^\d-^.]/g,'');
			var negPrefix = value.startsWith('-') ? '-' : '';
			value = negPrefix + value.replace(/[^\d\.]/g, '');
			var amount = Number(value).toLocaleString(localeCode, {
				style: 'currency',
				currency: currencyCode,
				minimumFractionDigits: 2,
				maximumFractionDigits: 4,
				currencyDisplay: 'code'
			});
			var replaceChars = "(" + currencyCode + "|\u200F|\u00A0)+";
			var replaceRegEx = new RegExp("^" + replaceChars + "|" + replaceChars + "$", "g");
			amount = amount.replace(replaceRegEx, '');
			return {
				amount: amount,
				type: currencyCode
			};
		};
	}
});

 


Related Problem: PRB1326824

Seen In

London Patch 5
SR - IRM - GRC Profiles - Madrid 2019 Q2
SR - IRM - Policy and Compliance - Madrid 2019 Q2
SR - IRM - Risk Management - New York 2019 Q3
SR - Security - Integration Framework - Madrid 2019 Q2
SR - Security - Support Common - Madrid 2019 Q2
SR - Security - Support Orchestration - Madrid 2019 Q2
SR - SIR - Security Incident Response - Madrid 2019 Q2
SR - SIR - Security Incident Response PA Content - New York 2019 Q3
SR - SIR - Store SecOps Setup Assistant - Madrid 2019 Q2
SR - SIR - Store Threat Core - Madrid 2019 Q2
SR - SIR - Store Trusted Security Circles Client - New York 2019 Q3
SR - VR - Vulnerability Response - New York 2019 Q3

Intended Fix Version

Madrid Patch 10
Orlando

Fixed In

New York Patch 6

Safe Harbor Statement

This "Intended Fix Version" information is meant to outline ServiceNow's general product direction and should not be relied upon in making a purchasing decision. The information provided here is for information purposes only and may not be incorporated into any contract. It is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. The development, release, and timing of any features or functionality described for our products remains at ServiceNow's sole discretion.

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2020-01-07 10:03:00
Published:2019-08-07