N/task Module: Asynchronous Task Management in SuiteScript
The N/task module in SuiteScript enables developers to manage various background tasks asynchronously, including CSV imports and document processing.
The N/task module provides SuiteScript developers the ability to create and manage asynchronous tasks within NetSuite efficiently. This functionality is critical for running heavier scripts without blocking user interactions or server congestion. Developers can leverage this module for a range of tasks, such as submitting scheduled scripts, executing map/reduce scripts, and importing CSV files.
Key Features of the N/task Module
The N/task module offers various capabilities, including:
- CSV Import Tasks: Use the
CsvImportTaskobject to import record data. - Document Capture Tasks: Utilize the
DocumentCaptureTaskto extract information from documents automatically. - Entity Deduplication Tasks: Use the
EntityDeduplicationTaskfor merging duplicate records in your system. - Map/Reduce and Query Tasks: Perform complex data processing using
MapReduceScriptTaskandQueryTaskobjects. - Workflow Trigger Tasks: Initiate workflows asynchronously via
WorkflowTriggerTask.
Each type of task created through the N/task module has its own object type and specific methods for configuration, submission, and monitoring. Tasks are inherently asynchronous, allowing the system to handle various operations without user interface interruptions.
Detailed Overview of Task Types
1. CsvImportTask
The CsvImportTask object allows you to submit tasks for importing CSV files into NetSuite. Key properties include:
| Property Name | Type | Description |
|---|---|---|
CsvImportTask.id | string | The ID of the task. |
CsvImportTask.importFile | file.File or string | The CSV file to be imported. |
CsvImportTask.name | string | Name for the CSV import task. |
2. DocumentCaptureTask
The DocumentCaptureTask handles document processing tasks.
| Property Name | Type | Description |
|---|---|---|
DocumentCaptureTask.inputFile | file.File | The document to extract content from. |
DocumentCaptureTask.documentType | string | The type of document being processed. |
Example Code Snippet
Here’s a simple example of how to create and submit a CSV import task:
1define(['N/task'], function(task) {2 function submitCsvImportTask() {3 var csvTask = task.create({ taskType: task.TaskType.CSV_IMPORT });4 csvTask.importFile = file.load({ id: 'path/to/your/file.csv' });5 var taskId = csvTask.submit();6 log.debug('CSV Import Task Submitted', 'Task ID: ' + taskId);7 }8});Who This Affects
- Developers: Those building custom scripts that require background processing.
- Administrators: Users managing data import processes and duplicate records.
Key Takeaways
- The N/task module enables efficient asynchronous task management in SuiteScript.
- Various task types cater to specific needs such as CSV imports, document processing, and deduplication.
- Understanding the properties and methods of each task type is essential for effective script development.
Frequently Asked Questions (4)
Do I need specific permissions to use the N/task module in SuiteScript 2026.1?
Is the CsvImportTask suitable for handling large CSV files in SuiteScript 2026.1?
How does the MapReduceScriptTask handle input and output in SuiteScript 2026.1?
Can WorkflowTriggerTask trigger multiple workflows simultaneously in SuiteScript 2026.1?
Weekly Update History (1)
Updated the N/task Module section to include objects and values related to document capture: Added task.DocumentCaptureTask and task.DocumentCaptureTaskStatus objects Added the DOCUMENT_CAPTURE value to task.TaskType
View Oracle DocsWas this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Custom Tool Script Enhancements in NetSuite
Custom tool scripts in NetSuite gain execution log support and a new management page in February 16, 2026.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
