function getLength ( lengthparam ) { try { let length = lengthparam.length let orgLength = Number( length ) / 2 let hexString = orgLength.toString( 16 ) if ( hexString.length < 2 ) { hexString = “0” + hexString; } return hexString } catch ( e ) { log.error( “error@getLength”, e ) } }
Category: SuiteScript Functions
SuiteScript Functions related articles will be posted in this category
Function to Render Template File
Function to remove duplicates from the array
Function to remove duplicates from the array
How to change currency sign into different symbol
If we have to change the currency sign or have to put different currency sign there. Then we can use this method there for getting the values. After assigning the currency just call it before the value where we want to put. For Eg: ${currencyType}
Convert Array to CSV
/** * Converts a value to a string appropriate for entry into a CSV table. E.g., a string value will be surrounded by quotes. * @param {string|number|object} theValue * @param {string} sDelimiter The string delimiter. Defaults to a double quote (“) if omitted. */function toCsvValue(theValue, sDelimiter) { try { var t = typeof (theValue), output;… Continue reading Convert Array to CSV
Divide Array to Chunks
/** * Dividing into array of arrays. * @param array Array to be divided * @param size length of trimmed array * */ function chunkArray(array, size) { try { let result = [] for (let i = 0; i < array.length; i += size) { let chunk = array.slice(i, i + size) result.push(chunk) } log.debug(‘result’,… Continue reading Divide Array to Chunks
Item search for getting available Bins for an item
/** *@description Available bin search – This function will return object of bin name and their quantity * @param itemName Name of the item * @return {Object} */function availableBinSearch(itemName) { try { var itemSearchObj = search.create({ type: “item”, filters: [ [“name”, “is”, itemName.toString()], “AND”, [“inventorydetail.binnumber”, “noneof”, “@NONE@”], “AND”, [“binonhand.quantityavailable”, “greaterthan”, “0”] ], columns: [ search.createColumn({… Continue reading Item search for getting available Bins for an item
Calculate Number of Business Days between Two Dates
Item Location Configuration search
// search for item location configuration using itemid and get the supplytype of the location function itemLocConfigSearch(itemId){ try { let supplytypeItemobj = {}; let itemSearch = search.create({ type: record.Type.ITEM_LOCATION_CONFIGURATION, filters: [ [‘item’, ‘is’, itemId] ], columns: [ search.createColumn({name: “supplytype”, label: “Supply Type”}) ] }); let searchResultCount = itemSearch.runPaged(); searchResultCount.pageRanges.forEach(function (pageRange) { let myPage = searchResultCount.fetch({… Continue reading Item Location Configuration search
Node Functions
Node functions