/**
* @NApiVersion 2.1
* @NScriptType MapReduceScript
* @NModuleScope SameAccount
*/
define([ 'N/runtime', 'N/record', 'N/search'],
(runtime, record, search) => {
getInputData = () => {
log.debug('===START===');
const scriptObj = runtime.getCurrentScript();
const savedSearch = scriptObj.getParameter({name: 'custscript_saved_search'});
const searchObj = search.load({
id: savedSearch
});
return searchObj;
}
map = (context) => {
log.debug('map context', context);
try {
const salesOrderRecord = record.load({
type: record.Type.SALES_ORDER,
id: context.key,
isDynamic: true
});
const lineCount = salesOrderRecord.getLineCount({sublistId: 'item'});
for (let i = 0; i < lineCount; i++) {
salesOrderRecord.selectLine({sublistId: 'item',line: i});
salesOrderRecord.setCurrentSublistValue({sublistId: 'item',fieldId: 'isclosed',value: true});
salesOrderRecord.commitLine({sublistId: 'item'});
}
salesOrderRecord.save();
}
catch(e) {
let message = e.message + ' : ' + JSON.stringify(e);
log.error('Error', message);
}
}
summarize = (summary) => {
log.debug('==END==','==END==');
}
return {
getInputData: getInputData,
map: map,
summarize: summarize
};
});
Jaime Requena is a seasoned NetSuite Consultant and Solutions Architect, known for delivering WHITE GLOVE service to businesses. With 15+ years of experience and 3x certifications in ERP, Developer, and Admin, Jaime specializes in highly customized NetSuite accounts, transforming operations for 200+ satisfied customers all across the globe.
We aim to bring unmatched expertise and professionalism to your NetSuite initiatives. Let’s talk about how our NetSuite consultancy can make a difference!
It’s Been 4+ Years Now And We Have Worked With Hundreds Of Clients, Building Our Way To The Top, One Happy Client After Another! Their Voices Of Satisfaction Serve As A Testament To Our Success –