N/task Module
Use the N/task module to create tasks and place them in the internal NetSuite scheduling or task queue. You can use this module to create tasks for the following:
-
To submit a scheduled script
-
To run a map/reduce script
-
To import CSV files
-
To merge duplicate records
-
To execute asynchronous searches, constructed queries, SuiteQL queries, and workflows
Each task is a specific task type (task.TaskType) and each task type has its own corresponding object types. Use the methods available to each object type to configure, submit, and monitor the tasks.
Regardless of task type, tasks are always triggered asynchronously.
In This Help Topic
N/task Module Members
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Object |
Object |
Server scripts |
The properties of a CSV import task. Use the methods and properties for this object to submit a CSV import task into the task queue and asynchronously import record data into NetSuite. |
|
Object |
Server scripts |
The status of a CSV import task placed into the NetSuite scheduling queue. |
||
Object |
Server scripts |
All the properties of a merge duplicate records task request. Use the methods and properties of this object to submit a merge duplicate record job task into the NetSuite task queue. |
||
Object |
Server scripts |
The status of a merge duplicate record task placed into the NetSuite task queue. |
||
Object |
Server scripts |
A map/reduce script deployment. |
||
Object |
Server scripts |
The status of a map/reduce script deployment that has been submitted for processing. |
||
Object |
Server scripts |
The properties of a record action task. Use this object to place a record action task into the NetSuite scheduling queue. |
||
Object |
Server scripts |
The status of a record action task in the NetSuite scheduling queue. |
||
Object |
Server scripts |
All the properties of a scheduled script task in SuiteScript. Use this object to place a scheduled script deployment into the NetSuite scheduling queue. |
||
Object |
Server scripts |
The status of a scheduled script placed into the NetSuite scheduling queue. |
||
Object |
Server scripts |
The properties required to initiate an asynchronous search. |
||
Object |
Server scripts |
The status of an asynchronous search initiation task that is placed into the NetSuite task queue. |
||
Object |
Server scripts |
All the properties required to asynchronously initiate a workflow. Use WorkflowTriggerTask to create a task that initiates an instance of a specific workflow. |
||
Object |
Server scripts |
The status of an asynchronous workflow initiation task placed into the NetSuite task queue. |
||
Method |
task.CsvImportTaskStatus | task.EntityDeduplicationTaskStatus | task.MapReduceScriptTaskStatus | task.RecordActionTaskStatus | task.ScheduledScriptTaskStatus | task.SearchTaskStatus |task.WorkflowTriggerTaskStatus |
Server scripts |
Returns a task status object associated with a specific task ID. |
|
task.CsvImportTask | task.EntityDeduplicationTask | task.MapReduceScriptTask | task.RecordActionTask | task.ScheduledScriptTask | task.SearchTask | task.WorkflowTriggerTask |
Server scripts |
Creates an object for a specific task type and returns the task object. |
||
Enum |
enum |
Server scripts |
Holds the string values for the possible record action conditions. |
|
enum |
Server scripts |
Holds the string values for entity types for which you can merge duplicate records with task.EntityDeduplicationTask. |
||
enum |
Server scripts |
Holds the string values for available deduplication modes when merging duplicate records with task.EntityDeduplicationTask. |
||
enum |
Server scripts |
Holds the string values for the stages of a map/reduce script deployment, which is encapsulated by the task.MapReduceScriptTask object. |
||
enum |
Server scripts |
Holds the string values for supported master selection modes when merging duplicate records with task.EntityDeduplicationTask. |
||
enum |
Server scripts |
Holds the string values for the possible status of tasks created and submitted with the N/task Module. |
||
enum |
Server scripts |
Holds the string values for the types of task objects you can create using task.create(options). |
CsvImportTask Object Members
The following members are available for a task.CsvImportTask object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
string |
Server scripts |
Directs NetSuite to place a CSV import task into the NetSuite task queue and returns a unique ID for the task. You can use this method only in bundle installation scripts, scheduled scripts, and RESTlets. |
|
Property |
string |
Server scripts |
The ID of the task. |
|
file.File | string |
Server scripts |
CSV file to import. Use a file.File object or a string that represents the CSV text to be imported. |
||
Object |
Server scripts |
A map of key/value pairs that sets the data to be imported in a linked file for a multi-file import job, by referencing a file in the File Cabinet or the raw CSV data to import. |
||
number | string |
Server scripts |
Script ID or internal ID of the saved import map that you created when you ran the Import Assistant. |
||
string |
Server scripts |
Name for the CSV import task. |
||
number |
Server scripts |
Overrides the Queue Number property under Advanced Options on the Import Options page of the Import Assistant. |
CsvImportTaskStatus Object Members
The following members are available for a task.CsvImportTaskStatus object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Property |
string (read-only) |
Server scripts |
Status for a CSV import task. Returns a task.TaskStatus enum value. |
|
string (read-only) |
Server scripts |
The task ID associated with the specified task. |
EntityDeduplicationTask Object Members
The following members are available for a task.EntityDeduplicationTask object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
string |
Server scripts |
Directs NetSuite to place the merge duplicate records task into the NetSuite task queue and returns a unique ID for the task. |
|
Property |
string |
Server scripts |
The mode in which to merge or delete duplicate records. Use values from the task.DedupeMode enum. |
|
string |
Server scripts |
The type of entity on which you want to merge duplicate records. Use a task.DedupeEntityType enum to set the value. |
||
string |
Server scripts |
The ID of the task. |
||
number |
Server scripts |
Master record ID. When you merge duplicate records, you can delete all duplicates for a record or merge information from the duplicate records into the master record. |
||
string |
Server scripts |
Master selection mode. Use values from the task.MasterSelectionMode enum. |
||
number[] |
Server scripts |
Number array of record internal IDs to perform the merge or delete operation on. |
EntityDeduplicationTaskStatus Object Members
The following members are available for a task.EntityDeduplicationTaskStatus object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Property |
string (read-only) |
Server scripts |
Status for a merge duplicate record task. Returns a task.TaskStatus enum value. |
|
string (read-only) |
Server scripts |
The task ID associated with the specified task. |
MapReduceScriptTask Object Members
The following members are available for a task.MapReduceScriptTask object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
string |
Server scripts |
Submits a map/reduce script deployment for processing. |
|
Property |
string |
Server scripts |
Script ID (as a string), for the script deployment record for a map/reduce script. |
|
string |
Server scripts |
The ID of the task. |
||
Object |
Server scripts |
Object that represents key/value pairs that override static script parameter field values on the script deployment record. |
||
number | string |
Server scripts |
Internal ID (as a number), or script ID (as a string), for the map/reduce script record. |
MapReduceScriptTaskStatus Object Members
The following members are available for a task.MapReduceScriptTaskStatus object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
number |
Server scripts |
Returns the total size in bytes of all stored work in progress by a task.MapReduceScriptTask. |
|
number |
Server scripts |
Returns the total number of records or rows not yet processed by the map stage of a task.MapReduceScriptTask. |
||
number |
Server scripts |
Returns the total number of bytes not yet processed by the map stage, as a component of total size, of a task.MapReduceScriptTask. |
||
number |
Server scripts |
Returns the total number of records or rows not yet processed by a task.MapReduceScriptTask. |
||
number |
Server scripts |
Returns the total size in bytes of all key/value pairs written as output, as a component of total size, by a task.MapReduceScriptTask. |
||
number |
Server scripts |
Returns the total number of records or rows not yet processed by the reduce stage of a task.MapReduceScriptTask. |
||
number |
Server scripts |
Returns the total number of bytes not yet processed by the reduce stage, as a component of total size, of a task.MapReduceScriptTask. |
||
number |
Server scripts |
Returns the current percentage complete for the current stage of a task.MapReduceScriptTask. |
||
number |
Server scripts |
Returns the total number of records or rows passed as input to the map stage of a task.MapReduceScriptTask. |
||
number |
Server scripts |
Returns the total number of records or rows passed as inputs to the output phase of a task.MapReduceScriptTask. |
||
number |
Server scripts |
Returns the total number of record or row inputs to the reduce stage of a task.MapReduceScriptTask. |
||
Property |
string (read-only) |
Server scripts |
Script ID for a script deployment record associated with a specific task.MapReduceScriptTask. |
|
number (read-only) |
Server scripts |
Internal ID for a map/reduce script record associated with a specific task.MapReduceScriptTask. |
||
string (read-only) |
Server scripts |
The current stage of a map/reduce script deployment that is being processed. See task.MapReduceStage for supported values. |
||
string (read-only) |
Server scripts |
Status for a map/reduce script task. Returns a task.TaskStatus enum value. |
||
string (read-only) |
Server scripts |
The task ID associated with the specified task. |
QueryTask Object Members
The following members are available for a task.QueryTask object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
void |
Server scripts |
Adds a scheduled script task or map/reduce script task to the query task as a dependent task. |
|
string |
Server scripts |
Submits the query task for asynchronous processing and returns the task ID. |
||
Property |
number |
Server scripts |
Internal ID of the CSV file to export query results to. This property is mutually exclusive with the QueryTask.filePath parameter. |
|
string |
Server scripts |
Path of the CSV file to export query results to. This property is mutually exclusive with the QueryTask.fileId property. |
||
Object[] |
Server scripts |
Key-value pairs that contain information about the dependent tasks added to the query task. |
||
string |
Server scripts |
Query definition for the query task. |
QueryTaskStatus Object Members
The following members are available for a task.QueryTaskStatus object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Property |
number (read-only) |
Server scripts |
Internal ID of the CSV file that query results are exported to. |
|
query.Query (read-only) |
Server scripts |
Query definition for the submitted query task. |
||
string (read-only) |
Server scripts |
Status of the submitted query task. |
||
string (read-only) |
Server scripts |
ID of the submitted query task. |
RecordActionTask Object Members
The following members are available for a task.RecordActionTaskStatus object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
string |
Server scripts |
Submits a record action task for processing and returns its task ID. |
|
Property |
string |
Server scripts |
The ID of the action to be invoked. |
|
Object |
Server scripts |
The condition used to select record IDs of records for which the action is to be executed. Only the action.ALL_QUALIFIED_INSTANCES constant is currently supported. |
||
string |
Server scripts |
The ID of the task. |
||
Object |
Server scripts |
Function that takes record ID and returns the parameter object for the specified record ID. |
||
Object[] |
Server scripts |
An array of parameter objects. Each object corresponds to one record ID of the record for which the action is to be executed. The object has the following form: {recordId: 1, someParam: 'example1', otherParam: 'example2'} |
||
string |
Server scripts |
The record type on which the action is to be performed. For a list of record types, see record.Type. |
RecordActionTaskStatus Object Members
The following members are available for a task.RecordActionTaskStatus object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Property |
number (read-only) |
Server scripts |
The number of record action tasks with a completed status. |
|
Object (read-only) |
Server scripts |
The error details of failed action executions. The value of the property is the record instance ID and the corresponding error details. The error details are returned in an unnamed object with two properties: code and message. |
||
number (read-only) |
Server scripts |
The number of record action tasks with a failed status. |
||
number (read-only) |
Server scripts |
The number of record action tasks with a pending status. |
||
Object (read-only) |
Server scripts |
The results of successfully executed record action tasks. The value of the property is the task instance ID and the corresponding action result. |
||
string (read-only) |
Server scripts |
Represents the record action task status. Returns a value from the task.TaskStatus enum. |
||
number (read-only) |
Server scripts |
The number of record action tasks with a succeeded status. |
||
string (read-only) |
Server scripts |
The task ID associated with the specified task. |
ScheduledScriptTask Object Members
The following members are available for a task.ScheduledScriptTask object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
string |
Server scripts |
Directs NetSuite to place a scheduled script deployment into the NetSuite scheduling queue and returns a unique ID for the task. |
|
Property |
string |
Server scripts |
Script ID (as a string), for the script deployment record associated with a task.ScheduledScriptTask object. |
|
string |
Server scripts |
The ID of the task. |
||
Object |
Server scripts |
Object with key/value pairs that override the static script parameter field values on the script deployment. |
||
number | string |
Server scripts |
Internal ID (as a number), or script ID (as a string) for the script record associated with a task.ScheduledScriptTask object. |
ScheduledScriptTaskStatus Object Members
The following members are available for a task.ScheduledScriptTaskStatus object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Property |
string (read-only) |
Server scripts |
Script ID for a script deployment record associated with a specific task.ScheduledScriptTask object. |
|
number (read-only) |
Server scripts |
Internal ID for a script record associated with a specific task.ScheduledScriptTask object. |
||
string (read-only) |
Server scripts |
Status for a scheduled script task. Returns a task.TaskStatus enum value. |
||
string (read-only) |
Server scripts |
The task ID associated with the specified task. |
SearchTask Object Members
The following members are available for a task.SearchTask object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
void |
Server scripts |
Adds a scheduled script task or map/reduce script task to the search task as a dependent script. Dependent scripts are processed automatically when the search task is complete. For more information, see SuiteCloud Processors. |
|
string |
Server scripts |
Places the asynchronous search initiation task into the SuiteScript task queue, and returns a unique ID for the task. |
||
Property |
number |
Server scripts |
ID of the CSV file to export search results into. |
|
string |
Server scripts |
Path of the CSV file to export search results into. |
||
string |
Server scripts |
The ID of the task. |
||
Object[] (read-only) |
Server scripts |
Key/value pairs to describe the dependent scripts added to the search task. |
||
number |
Server scripts |
ID of the saved search to be executed during the task. |
SearchTaskStatus Object Members
The following members are available for a task.SearchTaskStatus object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Property |
number (read-only) |
Server scripts |
ID of the CSV file into which search results are exported. |
|
number (read-only) |
Server scripts |
ID of the saved search executed during the task. |
||
string (read-only) |
Server scripts |
Status of an asynchronous search task placed in the NetSuite task queue. Returns one of the task.TaskStatus enum values. |
||
string (read-only) |
Server scripts |
ID of the asynchronous task. |
SuiteQLTask Object Members
The following members are available for a task.SuiteQLTask object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
void |
Server scripts |
Adds a scheduled script task or map/reduce script task to the SuiteQL task as a dependent task. |
|
string |
Server scripts |
Submits the SuiteQL task for asynchronous processing and returns the task ID. |
||
Property |
number |
Server scripts |
Internal ID of the CSV file to export SuiteQL query results to. This property is mutually exclusive with the SuiteQLTask.filePath parameter. |
|
string |
Server scripts |
Path of the CSV file to export SuiteQL query results to. This property is mutually exclusive with the SuiteQLTask.fileId property. |
||
Object[] |
Server scripts |
Key-value pairs that contain information about the dependent tasks added to the SuiteQL task. |
||
Array<string | boolean | number> |
Server scripts |
Parameters for the SuiteQL query. |
||
string |
Server scripts |
SuiteQL query definition for the SuiteQL task. |
SuiteQLTaskStatus Object Members
The following members are available for a task.SuiteQLTaskStatus object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Property |
number (read-only) |
Server scripts |
Internal ID of the CSV file that SuiteQL query results are exported to. |
|
Array<string | boolean | number> (read-only) |
Server scripts |
Parameters for the SuiteQL query. |
||
string (read-only) |
Server scripts |
SuiteQL query definition for the SuiteQL task. |
||
string (read-only) |
Server scripts |
Status of the SuiteQL task. |
||
string (read-only) |
Server scripts |
ID of the submitted SuiteQL task. |
WorkflowTriggerTask Object Members
The following members are available for a task.WorkflowTriggerTask object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
string |
Server scripts |
Directs NetSuite to place the asynchronous workflow initiation task into the NetSuite scheduling queue and returns a unique ID for the task. |
|
Property |
string |
Server scripts |
The ID of the task. |
|
Object |
Server scripts |
Object that contains key/value pairs to set default values on fields specific to the workflow. |
||
number |
Server scripts |
Internal ID of the workflow definition base record. For example, 55 or 124. |
||
string |
Server scripts |
Record type of the workflow base record. For example, customer, salesorder, or lead. |
||
number | string |
Server scripts |
Internal ID (as a number), or script ID (as a string), for the workflow definition. |
WorkflowTriggerTaskStatus Object Members
The following members are available for a task.WorkflowTriggerTaskStatus object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Property |
string (read-only) |
Server scripts |
Status for a asynchronous workflow placed in the NetSuite task queue. Returns a value from the task.TaskStatus enum. |
|
string (read-only) |
Server scripts |
The task ID associated with the specified task. |