N/task Module: Asynchronous Task Management in SuiteScript
The N/task module enables asynchronous management of tasks like CSV imports and document processing in SuiteScript.
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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category