top of page
Search

EMEA and APAC localisation in SuiteScript 2.0


SuiteCloud Development for accounts in EMEA and APAC requires a thorough understanding of localisation. A particular problem may be Date Formatting:

  1. On the one hand, principal SuiteScript API methods such as search.create and record.create require date field value input as a string, hence “31/5/2018” for example. The format of field value input depends on specific fields in the account settings.

  2. On the other hand, while Date Formatting in the US may follow the format M/D/YY, APAC generally follows the format DD/MM/YYYY (except for Japan with the ISO compliant YYYY/MM/DD) and in EMEA, formats vary from DD/MM/YYYY to D.M.YYYY.

Here we give quick answer to related questions. Question 1: What decides the format in which I need to populate the field date? Answer 1: It’s the Date Format setting on your Company Information. HOWEVER, if you use a OneWorld account, it’s not the Company Information, BUT the Subsidiary Settings of your primary entity. Navigate to Setup > Company > Subsidiaries > Subsidiary List and identify the top account. (You can also check a financial report or install that neat SuiteApp “Subsidiary Navigator” to get a quick visual overview of the parent company.) Take note that this setting will impact all users in the respective entity. Hence, it is more prudent to adjust the script. Question 2: Is there no API method to format according to these UI settings? Answer 2: As of July 2018, there is no direct API method. However, you could call on company preferences via var objConf = config.load({ type: config.Type.COMPANY_PREFERENCES }); or subsidiary preferences via                    var objConf = {}; var objSearchSubsidiary = search.create({ type: search.Type.SUBSIDIARY, filters: [ [“parent”,”isempty”,””] ], columns: [ “internalid”, “name” ] }); var objResultSubsidiary = subsidiarySearchObj.runPaged(); subsidiarySearchObj.run().each(function(result){ // You should only get one row anyway objConf[“subid”] = result.getValue(“internalid”); objConf[“name”] = result.getValue(“name”); return true; }); var arrDateType = search.lookupFields({ type: search.Type.SUBSIDIARY, id: objConf[“subid”], columns: “dateformat” }); objConf[“dateformat”] = arrDateType[0];

Subsequently, you can write a switch case statement for the different formatting methods extracted in objConf[“dateformat”].

NetSuite SuiteScript 2.0 offers the N/format module to parse and stringify date objects and strings respectively. While the respective methods offer types for DATE and DATETIME as well as time zones, they do not take regional date format settings into consideration. Feel free to join our voice with enhancement requests to have this introduced swiftly. Question 3: Is there any other way? Answer 3: At Cloudmaven, we work both with the N/format module, but in case of certain cases the format not working, we sometimes have to resort to the following functions we embed as a script library file or call upon from our freely available _oro_1010_custom_modules bundle. (Unless for more complex bundles, we do not introduce JS libraries such as moment.js for reason of simplicity and code maintenance. For more details on custom modules, stay tuned for an upcoming blog entry.) Here a few simple functions of ours. Parsing a date into a format specified in the script parameter settings.

             var strDate = “31/5/2018”; var splitter = “/”; // In this case, this is hardcoded. Make sure you source this parameter from objConf. function parseDate(strDate,splitter) { var arrDateParts = strDate.split(splitter); // Please pay attention to the month (parts[1]); JavaScript counts months from 0: // January – 0, February – 1, etc. var objDate = new Date(arrDateParts[2], arrDateParts[1] – 1, arrDateParts[0]); return objDate } Adding days to a date: function addDays(date, days) { var result = new Date(date); result.setDate(result.getDate() + days); return result; } Deducting months from a date. function addMonths (date, months) { if (date && months) { var m, d = (date = new Date(+date)).getDate(); date.setMonth(date.getMonth() + months, 1); m = date.getMonth() date.setDate(d) if (  date.getMonth() !== m  ) { date.setDate(0); } } date.setDate((date).getDate() + 1); return date }

This and other methods are found in our freely available _oro_1010_custom_modules bundle. Drop us a line if you would like to have it shared.

126 views0 comments

Recent Posts

See All

Comments


Talk to our experts to start your Automation ERP journey. Click here
bottom of page