Function to set vendor pricing in item record.
Category: SuiteScript Functions
SuiteScript Functions related articles will be posted in this category
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; }
Date format using moment.js
MomentJS is a JavaScript library which helps in parsing, validating, manipulating and displaying date/time in JavaScript. Its parsing allows you to parse the date in the format required. Parsing of date is available in the string, object and array. You can use the method isValid() and check whether the date is valid or not. MomentJS also provides… Continue reading Date format using moment.js
Function to set landed cost in item receipt
Function to set landed cost in item receipt.
Special Character Function
This function used to resolve special character issue in the words.
Setting the class column in item sub list as mandatory from Company preferences through script
User may set the Class Field to mandatory by ticking the Make Classes Mandatory field on Setup > Accounting > Accounting Preferences > General tab. This can also be done via SuiteScript. var accountingPref = config.load({type: config.Type.ACCOUNTING_PREFERENCES}); accountingPref.setValue({fieldId: ‘CLASSMANDATORY’,value: true}); accountingPref.save();