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.

·2 min read·10 views·View Oracle Docs

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 CsvImportTask object to import record data.
  • Document Capture Tasks: Utilize the DocumentCaptureTask to extract information from documents automatically.
  • Entity Deduplication Tasks: Use the EntityDeduplicationTask for merging duplicate records in your system.
  • Map/Reduce and Query Tasks: Perform complex data processing using MapReduceScriptTask and QueryTask objects.
  • 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 NameTypeDescription
CsvImportTask.idstringThe ID of the task.
CsvImportTask.importFilefile.File or stringThe CSV file to be imported.
CsvImportTask.namestringName for the CSV import task.

2. DocumentCaptureTask

The DocumentCaptureTask handles document processing tasks.

Property NameTypeDescription
DocumentCaptureTask.inputFilefile.FileThe document to extract content from.
DocumentCaptureTask.documentTypestringThe type of document being processed.

Example Code Snippet

Here’s a simple example of how to create and submit a CSV import task:

javascript
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?
The article does not specify the required permissions for using the N/task module. It would be advisable to check NetSuite documentation or consult your NetSuite administrator for detailed permission requirements.
Is the CsvImportTask suitable for handling large CSV files in SuiteScript 2026.1?
CsvImportTask in the N/task module is designed for automating CSV file imports, but the article does not provide specific details about handling large files. NetSuite documentation or testing in a development environment may offer more insights.
How does the MapReduceScriptTask handle input and output in SuiteScript 2026.1?
The MapReduceScriptTask defines input and output for performing operations across large datasets. It uses a map-reduce paradigm to efficiently process these datasets.
Can WorkflowTriggerTask trigger multiple workflows simultaneously in SuiteScript 2026.1?
The article does not detail whether WorkflowTriggerTask can trigger multiple workflows simultaneously. Reviewing the task’s documentation or conducting tests within the NetSuite environment may provide clarity.

Weekly Update History (1)

SuiteScriptupdated

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 Docs
Source: In This Help Topic Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in SuiteScript

View all SuiteScript articles →