I'm a little new to the map-reduce script so pls b...
# suitescript
s
I'm a little new to the map-reduce script so pls bear with me this is the last line of our map function I would like to get a list of all the errors to the will that get based to the summarize summary.mapSummary.errors or do I need to use the recude function
Copy code
var id = fulfillmentRecord.save();
    log.debug({ title: "fulfillid", details: id });
    return id
s
you don't need to implement
reduce
in order to get all the
map
errors
s
so just return id above ? or dont even need that
that is the bottom of map fucntion
s
if your
map
throws an exception it should automatically make its way to the
mapSummary
you don't have to return anything from map
s
i see some people have a try-catch inside there map function is that needed or will NetSuite catch the error anway
s
yes the error will be caught, stop that execution of the map and keep executing the other invocations of map
try/catch could be necessary if you still need that invocation of the map to do something else, if you have no problem with it stopping, you don't need the try/catch
s
the context is it is creating item fulfillment if it errors on one order it will go to the next order with out try catch ?
s
If the next order is in the next invocation of map and not that same one (you don't have a loop in your map). I assume your getInput is returning some array of orders, if so, then yes the next order will get processed fine
s
get input is a search object which should return an array of object(orders)
s
you shouldn't try/catch in your map unless you are actually doing something as a result.
far too often I see people doing try/catch blindly, then even worse they just swallow the error so it's effectively lost.
s
that is what i thought
the code above is the bottom of the map function I was making sure if it fails a. will go to the next order b. all errors will be in summrize
i must be doing something wrong because right when it hits an error cant save an item fulfillment it wont go to the next order
Copy code
function getInputData() {
    day = new Date().getDay();
    if (day == 0 || day == 6) {
      log.debug(day, "skipped");
    } else {
      //step 1 pull int the data from saved search
      return search.load({
        id: 1271,
      });
    }
  }

  /**
   * Executes when the map entry point is triggered and applies to each key/value pair.
   */
  function map(context) {
    var data = JSON.parse(context.value);
s
The # of times map runs should be the same regardless of whether any of them throw an error or not. It's determined by the # of search results, and not by what happens in any other map instances. Try adding this line of logging to the top of the map function, to be sure that map is running for every result:
log.debug({ title: context.key, details: context.value });
You should see a log statement for every result in the search, even if some of the map instances throw an error
s
if the getinput data is returning 1000 orders what should the buffer size be ?
s
leave it at 1, the buffer size doesn't have anything to do with the # of results directly. I have had M/R scripts running with over 30,000 results and the buffer size was set to 1. I don't think increasing it will make any appreciable difference, but can cause problems if the script gets interrupted.
s
i thought it would speed up the exc
s
the concurrency, on the other hand, does make a big difference
I think it might speed things up slightly by reducing overhead, but I have tested it on large amounts of data and saw no measurable improvement
s
thanks this chat is so helpfull
does this return anything if it fails
Copy code
var recordId = objRecord.save
b
s
a record save will either succeed, returning the internal id of the record, or fail, throwing an error