/** * @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
Author: Vishnu P
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
Scheduled script has stopped on 12 am
To schedule a one time or recurring scheduled script submission: Set the Status field to Scheduled. Set the remaining body fields. On the Schedule subtab, set all deployment options. If you want the schedule to submit hourly on a 24-hour basis, use the following sample values as a guide: Deployed = checked Daily Event = [radio button… Continue reading Scheduled script has stopped on 12 am
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
Transfer Order partial fulfillment
/** * Transform TO to IF (partial and fully) * @param toInternalId * @param inventoryDetail * @return {Object} */ function transformTransferOrder(toInternalId,inventoryDetail) { var functionReturnObj = {} try { var errMsg; var itemFulfilment; try { var itemFulfilmentObj = record.transform({ fromType: record.Type.TRANSFER_ORDER, fromId: toInternalId, toType: record.Type.ITEM_FULFILLMENT, }); itemFulfilmentObj.setValue({ fieldId: ‘shipstatus’, value: ‘C’, ignoreFieldChange: true }); let itemCount=itemFulfilmentObj.getLineCount({sublistId:’item’})… Continue reading Transfer Order partial fulfillment
Extract xls file to Json
For implementing the function, need to implement excel js library function /** * file Extract function * @param {Number} fileId internal ID * @return {Object} returnDate Json Object */ function extractFileToJSON(fileId) { try { let returnData = []; let excelFile = file.load({ id: fileId }); let workbook = XLSX.read(excelFile.getContents(), {type: ‘base64’}); let firstSheetName = workbook.SheetNames[0];… Continue reading Extract xls file to Json
Multiple item names in item search criteria
Function /** * @description Multiple item names can be included in a single search limit is 1000 names per search via suitescript. * @param {Array} itemNameArray Array of item names (1000 item names) * @return {Object} */ function itemSearchforVendorUpdate(itemNameArray) { try { var b = “”; if (itemNameArray.length > 0) { for (var i =… Continue reading Multiple item names in item search criteria
Get System Notes content (Function)
Use the below code snippet to call any records system notes function(){//get one system note recordvar ss = search.create({ type: search.Type.SYSTEM_NOTE, columns: [‘date’, ‘recordtype’, ‘record’, ‘field’, ‘oldvalue’, ‘newvalue’], filters: [[‘role’, ‘is’, ‘3’]] //administrator }).run().getRange(0,1); return ss }