in the map/reduce stage do I need to return anythi...
# suitescript
s
in the map/reduce stage do I need to return anything from the map stage in order to get passed to summarize section
Copy code
var id = fulfillmentRecord.save();
b
m
You might want to add more context to your question especially when it comes to Map/Reduce scripts. But the answer is you don't have to if you aren't changing the keys since you can query the keys that are passed into Map. However, I don't think you can use the shuffle prior to reduce if your don't write out the keys.
s
so this map/reduce function fulfills our sales orders if it fails to save due to multiple reasons i want that the fails error to get passed to my summarize(summary)
this my current non-working code
Copy code
var id = fulfillmentRecord.save();
    }
  }
  function summarize(summary) {
    let data = "";
    let amount = "";
    let errors = "";
    summary.mapSummary.errors
      .iterator()
      .each(function (key, error, executionNo) {
        var errorObject = JSON.parse(error);
        log.error({ title: "fulfilerrors", details: errorObject });
        amount += 1;
        errors += `<td>${amount}</td><td> ${errorObject.name} </td > <td> ${
          errorObject.message || "No Meaningful message"
        } </td >`;
        return errors;
      });

    var date = new Date().toISOString().substring(0, 10);
    var time = `Total Seconds:  ${summary.seconds}`;
    var minutes = Math.floor(time / 60);
    var subject = `>The  fufil script ran for ${minutes} min ${JSON.stringify(
      summary.inputSummary.usage
    )} were created ${summary.usage}`;
    var info = ` <tr>${error}</tr>`;
m
Are you trying to create an email with the HTML?
If your trying to make some report or email I would look into
N/render
module. You can use an object or array to be able to populate data within a template.
s
Ok thanx but that would be the next step first problem is I'm not getting the info
m
You're saying that fulfillments that aren't saving are not showing as errors?
s
not in the summrize
m
And you aren't catching the errors within Map?
s
i was told that is bad practice not to catch them
if you catch them nothing gets passed to sumrize
m
You can catch them and log the error. But you will need to throw the error again so it gets registered as an error.
You can always parse the exception and just pass the message. It's up to you but you will need to throw something.
You can also configure Map to retry. This is nice because of the potential for
RECORD_HAS_CHANGED
error which is temporary. Then you can only throw the error on say the 2nd retry.