Are you currently working on a NetSuite account whose number formatting uses the European Decimal Notation (1.000.000,00)?

If yes, have you tried manipulating decimal fields through server-side scripts?

Recently, I just had a nerve-wracking experience in dealing with the European decimal notation on NetSuite Server-Side SuiteScripts.

When trying to use getSublistValue() on NetSuite server-side scripts, I wasn’t getting the values I was expecting. I used different combinations of API. I researched online. I utilized format.format and format.parse APIs. I came up with my own function of formatting European decimals to its American counterpart. See the below results: netsuite-eu-decimals

NetSuite UI ===> The amount shown in the NetSuite UI
getSublistText() ===> currentRecord.getSublistText({sublistId: 'item', fieldId:'field', line: i});
getSublistValue() ===> currentRecord.getSublistValue({sublistId: 'item', fieldId:'field', line: i});
format.format(getSublistValue())===> format.format({ value : currentRecord.getSublistValue({ sublistId: 'item', fieldId:'field', line: i }), type : format.Type.FLOAT });
formatDecimal(getText) ===> function formatDecimal(dec){
			finalDec = parseFloat((dec.replace(/\./g, '')).replace(",",".")); return finalDec; }

NOTHING worked!

Hours of troubleshooting passed and I noticed something… The issue only happens when the value has more than three decimals. Here you will see two mages that demonstrate the output from my test. When there are more than three decimals, SuiteScript is not returning favorable results. netsuite-eu-2-decimals-1 netsuite-eu-3-decimals-1 By this, you will assume that format.format(getSublistValue()) does seem to provide good results. However, it’s not necessarily true. I tried to test an amount that is more than 1,000 and the value returned was still inconsistent. netsuite-eu-3-decimals-2 Now, if I limit it to two decimals, the values would look something like this: netsuite-eu-2-decimals-2

As of this writing, we weren’t able to report this to NetSuite Support as we are currently limited on what we could file. So the solution that we went with was to limit the values to two decimals.

Have you ever encountered this issue? What solution did you go with? Let’s help a fellow NetSuite Developer in the EU community and share it here!

UPDATE: A client filed a Support Case for this and NetSuite Support was able to replicate the issue. However, a defect was not filed because it wasn’t reproducible after Release 2019.1.

LEACC Consulting is a team of NetSuite Certified Developers with IT experience solely dedicated to NetSuite technologies for eight years. We are experts in both SuiteScript 2.0 and SuiteScript 1.0. Our team has worked with 400+ NetSuite scripts and workflows combined. If you need some consulting help of how you can design your NetSuite scripts better, contact us by filling out this form or by commenting below.

Do you have NetSuite Development needs? Do you need help with a solution like this? Click on the link below and let’s have a chat about your project requirements!

Contact us for your NetSuite needs!

Leave a Reply