Saved search for fetching the items based on the SKUs /** * @description Saved search for fetching the items based on the SKUs * @param itemArray {Array}- Array of items in each Wineye order * @returns {Array} */ function fetchItemID(itemArray) { var stringArr = ”; var filter_name = ‘itemid’; for (var i = 0; itemArray.length… Continue reading Single Saved search for fetching multiple SKUs
Category: SuiteScript Functions
SuiteScript Functions related articles will be posted in this category
Check the account type
/** * @description Functions from N/config module encapsulated * @type {{isProduction(): boolean}} */const configFunction = { /** * To know whether the account is Production Environment or not * @returns {boolean} true when account is Production, false in all other scenarios */ isProduction() { var companyInfo = config.load({ type: config.Type.COMPANY_INFORMATION }); var ns_companyid = companyInfo.getValue({… Continue reading Check the account type
Check if the value is number or string
/** * @description To check whether the Given Value is a string or number * @param value * @returns {boolean} true if the given value is a string or number , else false */const isNumberOrString = (value) => { return (util.isString(value) || util.isNumber(value))};
To fix a float number to specified decimal parts
/** * @description To fix a float number to specified decimal parts * @param {Number|String} value * @param {Number|String} decimals * @returns {Number|String} */ const fixFloat = (value, decimals) => { decimals = (decimals) ? decimals : 2; // return roundFloat(parseFloat(value), parseInt(decimals)).toFixed(parseInt(decimals)); return parseFloat(value).toFixed(decimals); };
Round a float number
/** * @description To round a float number * @param {Number|String} value * @param {Number|String} decimals * @returns {Number} Floating Point Number with the given precision */ const roundFloat = (value, decimals) => { decimals = (decimals) ? decimals : 2; return Number(Math.round(parseFloat(value) + ‘e’ + parseInt(decimals)) + ‘e-‘ + parseInt(decimals)); };
Assign default value
/** * @description To assign a default value if the value argument is empty * @param {String|Number|Boolean|Object|Array|null|undefined} value * @param {String|Number|Boolean|Object|Array} defaultValue * @returns {*} either value or defaultValue */ const assignDefaultValue = function assignDefaultValue(value, defaultValue) { if (checkForParameter(value)) return value; else return defaultValue; }
Transforming transfer order based on item fulfillment
/** * * @param docNum * @param IFDetails * @param ifInternalId * @return {*|number} */ function IRcreation(docNum, IFDetails, ifInternalId) { try { let trecord = record.transform({ fromType: record.Type.TRANSFER_ORDER, fromId: docNum, toType: record.Type.ITEM_RECEIPT, isDynamic: true, defaultValues: {‘itemfulfillment’: ifInternalId.toString()} }); let itemCount = trecord.getLineCount({sublistId: ‘item’}); log.debug(‘in itemCount’, itemCount); for (let i = 0; i < itemCount; i++)… Continue reading Transforming transfer order based on item fulfillment
Change date format
/** * @description To format the Date Object into the given type/format * @param {Date} dateObj * @param {String} type * @returns {boolean|String} */ function formatDate(dateObj, type) { let dateAsKeys = splitDate(dateObj); if (dateAsKeys) switch (type) { case ‘MM/DD/YYYY’: ; case ‘M/D/YYYY’: return dateLogic.changeDateFormat(dateAsKeys, type, ‘/’); case ‘D/M/YYYY’: ; case ‘DD/MM/YYYY’: return changeDateFormat(dateAsKeys, type, ‘/’);… Continue reading Change date format
Generate date object with the given date
/** * To generate Date Object with the given data * @param {[Number,Number,Number]} dataArray * @returns {Date} */ function generateDate(dataArray) { if (dateLogic.checkDateFormat(dataArray)) return new Date(Number(dataArray[0]), Math.abs(Number(dataArray[1]) – 1) % 12, dataArray[2]); return new Date(‘false’); } /** * @description To check whether the given date is in format of [Number,Number,Number]. ie, [YYYY,MM,DD] * @param {dateArray}… Continue reading Generate date object with the given date
Function accepts UTF_8 format and returns hexadecimal value of input
function encodingString ( params ) { try { let hexEncodedString = encode.convert( { string: params, inputEncoding: encode.Encoding.UTF_8, outputEncoding: encode.Encoding.HEX } ); return ( hexEncodedString ) } catch ( e ) { log.error( “error@encodingString”, e ) } }