Timezone Used When Using JavaScript Date Object to Grab Current Time and Date

Running the sample script on the client side will use the time zone that the user’s device is using. If the computer time zone is set to EST then it will return the date and time in EST. Running the same script as a  User Event or a Scheduled Script will use NetSuite’s server time zone which is in PST. Developers… Continue reading Timezone Used When Using JavaScript Date Object to Grab Current Time and Date

Convert Date() to a Different Time Zone Using JavaScript

Scenario User would like to get the current date in a different time zone using JavaScript. Solution In the following code snippet, currDate variable holds the current date and time in the given time zone: var toTimeZone=”+5:30″;var tz;if(toTimeZone.search(“:”)==-1){tz=parseFloat(toTimeZone);}else{tz=parseFloat(toTimeZone.slice(0,toTimeZone.search(“:”)))+parseFloat(toTimeZone.slice(toTimeZone.search(“:”)+1)/60)}var date = new Date();var utc = date.getTime() + (date.getTimezoneOffset() * 60000);var currDate = new Date(utc + (3600000*tz));currDate = currDate.toString();var currDate… Continue reading Convert Date() to a Different Time Zone Using JavaScript

NetSuite dialog box with text field input

Using SuiteScript 2.0, it looks like you can create alert/confirmation boxes using their UI framework (using N/ur/dialog module). There’s a way to include a text input field (which the user can type into) on an alert or confirmation box.This is not officially supported, but seeing that N/ui/dialog is basically a wrapper function on Ext.js, you… Continue reading NetSuite dialog box with text field input

N/QUERY VS N/SEARCH

NetSuite provides us with the N/query and N/search modules to interact with these analytics features from our SuiteScript. GOVERNANCE USAGE For single-page result sets (less than 4000 for N/search and less than 5000 for N/query), the Governance usage of the two APIs is identical (a meager 10 units). For larger, multi-page result sets, N/query will… Continue reading N/QUERY VS N/SEARCH

Using @NAmdConfig

We can set up a custom module name to aid re-use. After configure a module name, we can require it without knowing the path. Custom module loading by name also enables better interoperability with third-party libraries and may offer some protection against naming conflicts. To load a custom module by name: Create the module file… Continue reading Using @NAmdConfig

Handling null/empty/undefined values in JavaScript

Javascript code to check if a given value is null,empty, or undefined using util library. var is_empty = function (_value) { if (typeof _value === “undefined” || _value === null) { return true; } else if (util.isString(_value) && (_value.trim() === “” || _value.length === 0)) { return true; } else if (util.isArray(_value) && _value.length ===… Continue reading Handling null/empty/undefined values in JavaScript