Something like this.
/**
◦ @NApiVersion 2.1
◦ @NScriptType MapReduceScript
*/
define(['N/record', 'N/search', 'N/log'], (record, search, log) => {
const map = (context) => {
let searchResult = JSON.parse(context.value);
let someDataToPass = {
id: se
archResult.id,
value: searchResult.values.someField
};
// Writing data to context to be used in the summarize stage
context.write({
key: se
archResult.id,
value: someDataToPass
});
};
const summarize = (summaryContext) => {
summaryContext.output.iterator().each((key, value) => {
// Process the data aggregated from the map stage
log.debug({
title: 'Processing ID: ' + key,
details: 'Value: ' + value
});
return true;
});
};
return {
map,
summarize
};
});