When copying records, you might need to reset fields whose values you do not want to get copied to the new record. It is very common to do this in the beforeLoad event (i.e. server-side): }) However, if the field in question is a multi-select field, the value did not get reset! To achieve the… Continue reading Resetting NetSuite Multi-Select Field Values Does Not Work in beforeLoad
Author: Sophia Yougin
Best practices to simplify your code
Declare and initialize your variables at the top Nothing disrupts readability like a late declaration. Just as it’s easier to take out all your tools before starting a job, it’s simpler to declare all variables before getting into the nitty-gritty of your function. This gives easy access should we need to tweak any name or… Continue reading Best practices to simplify your code
encodeURIComponent
The encodeURIComponent() function encodes a URI by replacing each instance of certain characters with one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two surrogate characters). Compared to encodeURI(), this function encodes more characters, including those that are part of… Continue reading encodeURIComponent
Function to evaluate an email address
Function to Remove falsy values from an array
Function to Remove Duplicated from Array
Function to format Saved Search column to key-value pair where each key represents each column in Saved Search
fetchSavedSearchColumn(savedSearchObj, priorityKey) {let columns = savedSearchObj.columns;let columnsData = {},columnName = ”;columns.forEach(function (result, counter) {columnName = ”;if (result[priorityKey]) {columnName += result[priorityKey];} else {if (result.summary)columnName += result.summary + ”; if (result.formula) columnName += result.formula + ”;if (result.join)columnName += result.join + ‘__’;columnName += result.name;}columnsData[columnName] = result;});return columnsData;},
Function to check whether the script is running in production
function isProduction() {var companyInfo = config.load({type: config.Type.COMPANY_INFORMATION});var ns_companyid = companyInfo.getValue({fieldId: ‘companyid’}).toString().trim().toLowerCase();if (Number.isNaN(Number(ns_companyid))) //Will be NaN for Sandbox or Release Preview accountsreturn false; }
SFTP_PERMISSION_DENIED” on File Upload From NetSuite to SFTP Servers via SuiteScript
User tries to upload Files from NetSuite to their SFTP server using the connection.upload(options) method within the sftp Module in SuiteScript 2.0 but encounters the error above. Whenever the user tries to connect to the SFTP or Download from the server, the script does not return an error. When checking the role permissions, the role… Continue reading SFTP_PERMISSION_DENIED” on File Upload From NetSuite to SFTP Servers via SuiteScript
JavaScript Tips and Best Practices-2
Use the map() function method to loop through an array’s items var squares = [1,2,3,4].map(function (val) {return val * val;});// squares will be equal to [1, 4, 9, 16] Avoid using with() Using with() inserts a variable at the global scope. Thus, if another variable has the same name it could cause confusion and overwrite the value.… Continue reading JavaScript Tips and Best Practices-2