The N/task module lets you programmatically create and submit task requests β such as scheduling a Map/Reduce script, a Scheduled script, a CSV import, or a workflow β directly from SuiteScript code.
Scheduling a Map/Reduce Script
define(["N/task", "N/log"], (task, log) => {
const mrTask = task.create({
taskType: task.TaskType.MAP_REDUCE,
scriptId: "customscript_my_mapreduce",
deploymentId: "customdeploy_my_mapreduce",
params: { custscript_batch_id: 12345 }
});
const taskId = mrTask.submit();
log.audit("MR Task submitted", taskId);
const status = task.checkStatus({ taskId });
log.debug("Task status", status.status);
return {};
});
Task Types
| Task Type | Description |
|---|---|
task.TaskType.MAP_REDUCE | Submit a Map/Reduce script execution |
task.TaskType.SCHEDULED_SCRIPT | Submit a Scheduled script execution |
task.TaskType.CSV_IMPORT | Trigger a CSV import job |
task.TaskType.ENTITY_DEDUPLICATION | Run an entity deduplication job |
task.TaskType.WORKFLOW_TRIGGER | Trigger a workflow on a set of records |
task.TaskType.RECORD_ACTION | Execute a Record Action script in bulk |