0
votes

I was hit SSS USAGE LIMIT EXCEEDED error in Netsuite. I plan to change the search to use Map Reduce Script, however, I didn't found any complete example to call Map Reduce Script, like how to pass parameter to Map Reduce Script and get the resultset from it. Would you please show me how? Thanks in advance

the below show how to define the task to call Map Reduce Script SuiteScript 2.0 UserEvent Script to Call Map Reduce

define(['N/record', 'N/log', 'N/Task'],
function (record, log, task) {
    function setFieldInRecord (scriptContext) {
        log.debug({
            'title': 'TESTING',
            'details': 'WE ARE IN THE FUNCTION!'
        });
        if (scriptContext.type === scriptContext.UserEventType.EDIT) {
            var scriptTask = task.create({
                taskType: task.TaskType.MAP_REDUCE
            });
            scriptTask.scriptId = 'customscript_id';
            scriptTask.deploymentId = 'customdeploy_id';
            var scriptTaskId = scriptTask.submit();
            //How to pass parameter to getInputData?
            //How to get the result?

        }
    }
    return {
        beforeSubmit: setFieldInRecord
    };
}

);

1
I get the answer how to pass parameter to getInputData. But I didn't know how to get the result from map or summary? Please let me know if you try before. Thanks in advance - Alak

1 Answers

1
votes

Map/Reduce script type provides you with 4 entry point functions to load/process your data:

  • getInputData(inputContext)
  • map(mapContext)
  • reduce(reduceContext)
  • summarize(summaryContext)

    Example:

    function summarize(context) { context.output.iterator().each(function(key, value) { // your logic here return true; }); }

Take a look at this help center section, there are examples (only available with NetSuite account): https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4387799161.html