mrob
10/12/2023, 10:58 PMbreak
? Netsuite makes it a pain to test these.raghav
10/12/2023, 10:59 PMmrob
10/12/2023, 11:00 PMreturn
statement?raghav
10/12/2023, 11:01 PMAnthony OConnor
10/12/2023, 11:26 PMmrob
10/12/2023, 11:29 PMmrob
10/12/2023, 11:29 PMAnthony OConnor
10/12/2023, 11:35 PMAnthony OConnor
10/12/2023, 11:37 PMmrob
10/12/2023, 11:38 PMmrob
10/12/2023, 11:39 PMAnthony OConnor
10/12/2023, 11:39 PMmrob
10/12/2023, 11:40 PMAnthony OConnor
10/12/2023, 11:41 PMmrob
10/12/2023, 11:41 PMmrob
10/12/2023, 11:41 PMAnthony OConnor
10/12/2023, 11:41 PMmrob
10/12/2023, 11:42 PMAnthony OConnor
10/12/2023, 11:42 PMmrob
10/12/2023, 11:43 PMAnthony OConnor
10/12/2023, 11:43 PMmrob
10/12/2023, 11:43 PMmrob
10/12/2023, 11:43 PMAnthony OConnor
10/12/2023, 11:43 PMmrob
10/12/2023, 11:43 PMAnthony OConnor
10/12/2023, 11:44 PMmrob
10/12/2023, 11:45 PMAnthony OConnor
10/12/2023, 11:46 PMmrob
10/12/2023, 11:46 PMAnthony OConnor
10/12/2023, 11:46 PMmrob
10/12/2023, 11:47 PMmrob
10/12/2023, 11:48 PMAnthony OConnor
10/12/2023, 11:48 PMAnthony OConnor
10/12/2023, 11:49 PMmrob
10/12/2023, 11:49 PMfunction getInputData() {
return "the quick brown fox \njumps over the lazy dog.".split('\n'); }
// After the getInputData function is executed, the system creates the following
// key/value pairs: //
// key: 0, value: 'the quick brown fox'
// key: 1, value: 'jumps over the lazy dog.'
Anthony OConnor
10/12/2023, 11:49 PMAnthony OConnor
10/12/2023, 11:49 PMmrob
10/12/2023, 11:49 PMmrob
10/12/2023, 11:49 PMAnthony OConnor
10/12/2023, 11:50 PMAnthony OConnor
10/12/2023, 11:50 PMmrob
10/13/2023, 12:08 AMAnthony OConnor
10/13/2023, 12:10 AMmrob
10/13/2023, 12:11 AMAnthony OConnor
10/13/2023, 12:12 AMbattk
10/13/2023, 12:12 AMmrob
10/13/2023, 12:13 AMmrob
10/16/2023, 6:29 PMreduce
stage would not be run? I've got
return {
getInputData: getInputData,
map: map,
reduce: reduce,
summarize: summarize
};
and then
function reduce(context) {
log.audit('hit reduce')
log.audit('reduce stage context', context)
parsedContext = JSON.parse(context)
....
but not seeing any logging. In my summary context I see {"type":"mapreduce.ReduceSummary","dateCreated":"2023-10-16T18:12:14.818Z","seconds":0,"usage":0,"concurrency":1,"yields":0}
mrob
10/16/2023, 6:30 PMmrob
10/16/2023, 6:30 PM{"type":"mapreduce.MapContext","isRestarted":false,"executionNo":1,"key":"5","value":"4327348"}
mrob
10/16/2023, 6:33 PMcatch
errors but reduce still doesn't seem to runmrob
10/16/2023, 6:35 PMbattk
10/16/2023, 6:36 PMmrob
10/16/2023, 6:38 PMmrob
10/16/2023, 6:38 PMbattk
10/16/2023, 6:38 PMmrob
10/16/2023, 6:39 PMmrob
10/16/2023, 6:40 PM// Passing the required data for reduce stage
context.write({ key: customerId, value: currency });
}
} catch (e) {
log.error('hit map catch', e)
}
log.audit('MAP STAGE CONTEXT', context)
}
mrob
10/16/2023, 6:40 PMmrob
10/16/2023, 6:42 PMlog.audit('MAP STAGE CONTEXT', context)
context.write({key: 'test', value: 'test'});
mrob
10/16/2023, 6:44 PMbattk
10/16/2023, 6:45 PMbattk
10/16/2023, 6:45 PMmrob
10/16/2023, 6:46 PMfunction map(context) {
try {
var searchResult = JSON.parse(context.value);
// log.audit('map stage searchResult', searchResult)
// Load the record and loop through all the lines to find customer/currency
var journalRecord = record.load({ type: 'journalentry', id: searchResult })
var currency = journalRecord.getValue('currency');
var lineCount = journalRecord.getLineCount({sublistId: 'line'});
for (var i = 0; i < lineCount; i++) {
var account = journalRecord.getSublistValue({sublistId: 'line', fieldId: 'account', line: i});
if (account != expenseAccountId) continue;
var customerId = journalRecord.getSublistValue({sublistId: 'line', fieldId: 'entity', line: i});
// Passing the required data for reduce stage
context.write({ key: customerId, value: currency });
}
} catch (e) {
log.error('hit map catch', e)
}
log.audit('MAP STAGE CONTEXT', context)
}
and the netsuite logs seemed to indicate that I was writing to the context with-
Audit MAP STAGE CONTEXT 10/16/2023 11:43 am -System- {"type":"mapreduce.MapContext","isRestarted":false,"executionNo":1,"key":"5","value":"4327348"}
mrob
10/16/2023, 6:47 PMbattk
10/16/2023, 6:49 PMmrob
10/16/2023, 6:49 PMbattk
10/16/2023, 6:50 PMmrob
10/16/2023, 6:50 PMcontext.write({ key: customerId, value: currency });
is below the continue and log.audit('MAP STAGE CONTEXT', context)
is later showing {"type":"mapreduce.MapContext","isRestarted":false,"executionNo":1,"key":"5","value":"4327348"}
battk
10/16/2023, 6:50 PMbattk
10/16/2023, 6:50 PMmrob
10/16/2023, 6:50 PMbattk
10/16/2023, 6:51 PMbattk
10/16/2023, 6:51 PMmrob
10/16/2023, 6:53 PMbattk
10/16/2023, 6:53 PMbattk
10/16/2023, 6:54 PMmrob
10/16/2023, 6:56 PMbattk
10/16/2023, 6:57 PMmrob
10/16/2023, 6:57 PMmrob
10/16/2023, 6:57 PMcontext.write({ key: customerId, value: currency });
mrob
10/16/2023, 6:57 PMbattk
10/16/2023, 6:58 PMmrob
10/16/2023, 6:58 PMif (account != expenseAccountId) continue;
is skipping every iteration of the line despite it being logged as part of the mapContext later in the map function?mrob
10/16/2023, 6:59 PMif (account != expenseAccountId) continue;
log.audit('after expense account', account)
battk
10/16/2023, 7:00 PM{
"type": "mapreduce.MapContext",
"isRestarted": false,
"executionNo": 1,
"key": "5",
"value": "4327348"
}
to see a key and value, and you are assuming that has a relation to the key and value that was writtenbattk
10/16/2023, 7:00 PMmrob
10/16/2023, 7:00 PMmrob
10/16/2023, 7:00 PMmrob
10/16/2023, 7:00 PMmrob
10/16/2023, 7:01 PMRyan Valizan
10/21/2023, 5:16 PMRyan Valizan
10/21/2023, 5:18 PMmrob
10/22/2023, 2:49 AMcontinue
prior to hitting my context.writeRyan Valizan
10/22/2023, 3:44 AM