Kris Wood
01/13/2020, 7:49 PMSandii
01/13/2020, 7:50 PMKris Wood
01/13/2020, 7:52 PMSandii
01/13/2020, 7:52 PMKris Wood
01/13/2020, 7:52 PMKris Wood
01/13/2020, 7:52 PMSandii
01/13/2020, 7:52 PMKris Wood
01/13/2020, 7:53 PMSandii
01/13/2020, 7:53 PMitemId is x
and type is invoice
, put your customer and whatever date you want in the resultsKris Wood
01/13/2020, 7:53 PMSandii
01/13/2020, 7:54 PMSandii
01/13/2020, 7:54 PMcontext.write(customerId, date)
to group the results by customerKris Wood
01/13/2020, 7:54 PMSandii
01/13/2020, 7:54 PMSandii
01/13/2020, 7:54 PMKris Wood
01/13/2020, 7:54 PMKris Wood
01/13/2020, 7:54 PMSandii
01/13/2020, 7:54 PMKris Wood
01/13/2020, 7:55 PMSandii
01/13/2020, 7:55 PMSandii
01/13/2020, 7:56 PMcontext = {
key: customerId,
values: [date1, date2, date3]
}
Sandii
01/13/2020, 7:57 PMKris Wood
01/13/2020, 7:58 PMKris Wood
01/13/2020, 7:58 PMSandii
01/13/2020, 7:58 PMcontext.write
with customer id as the keyKris Wood
01/13/2020, 8:00 PMSandii
01/13/2020, 8:01 PMSandii
01/13/2020, 8:01 PMdefine(['N/search'], function (search) {
var exports = {};
exports.getInputData = function getInputData() {
return /* insert item search here */
}
exports.map = function map(context) {
var results = JSON.parse(context.value);
var customer = results.values.mainlinename.value; //something close to this
var date = results.values.trandate; //or whatever date you want
context.write(customer, date);
}
exports.reduce = function reduce(context) {
var customer = context.key;
var datesForThisCustomer = context.values;
/* add some logic to find the most recent date */
}
}
Sandii
01/13/2020, 8:03 PMKris Wood
01/13/2020, 8:06 PMKris Wood
01/13/2020, 8:06 PMmichoel
01/13/2020, 9:19 PM