Function to check whether the Given Value is a string or number
Category: SuiteScript Functions
SuiteScript Functions related articles will be posted in this category
Function to assign a default value if the value argument is empty
Function to assign a default value if the value argument is empty
Function to get internal ID of Stock unit in account with Multiple units of measure
/** * @description Function to get internal ID of the stock unit * @param unitname – unit name * @param Wine_packsize – size need to be find out * @returns {*number*} */ function getStockUnit(unitTypeInternalID, unitname, wine_packsize) { log.debug(“unitname”, unitname); if (checkForParameter(unitTypeInternalID)) { var unitRec = record.load({ type: record.Type.UNITS_TYPE, id: unitTypeInternalID, isDynamic: false }); var linecount… Continue reading Function to get internal ID of Stock unit in account with Multiple units of measure
Single Saved search for fetching multiple SKUs
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
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