Trigger Map/Reduce Script Using Task Module via SuiteScript 2.0

A user requires a sample snippet to trigger a Map/Reduce script with Task module with custom script parameters.

let mapReduceData = new Object;
mapReduceData[“dataArray”] = dataArray

let mrTask = task.create({‌
taskType : task.TaskType.MAP_REDUCE
});
var scriptParams = {‌};
scriptParams.custscript_datastring = JSON.stringify(mapReduceData);

mrTask.scriptId = “customscript_generate_coupon_mr”;
mrTask.deploymentId = “customdeploy_generate_coupon_mr”;
mrTask.params = scriptParams;

mrTask.submit();.

Leave a comment

Your email address will not be published. Required fields are marked *