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:

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.

                                   
Note:

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

task.CsvImportTask

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.

task.CsvImportTaskStatus

Object

Server scripts

The status of a CSV import task placed into the NetSuite scheduling queue.

task.EntityDeduplicationTask

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.

task.EntityDeduplicationTaskStatus

Object

Server scripts

The status of a merge duplicate record task placed into the NetSuite task queue.

task.MapReduceScriptTask

Object

Server scripts

A map/reduce script deployment.

task.MapReduceScriptTaskStatus

Object

Server scripts

The status of a map/reduce script deployment that has been submitted for processing.

task.RecordActionTask

Object

Server scripts

The properties of a record action task.

Use this object to place a record action task into the NetSuite scheduling queue.

task.RecordActionTaskStatus

Object

Server scripts

The status of a record action task in the NetSuite scheduling queue.

task.ScheduledScriptTask

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.

task.ScheduledScriptTaskStatus

Object

Server scripts

The status of a scheduled script placed into the NetSuite scheduling queue.

task.SearchTask

Object

Server scripts

The properties required to initiate an asynchronous search.

task.SearchTaskStatus

Object

Server scripts

The status of an asynchronous search initiation task that is placed into the NetSuite task queue.

task.WorkflowTriggerTask

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.

task.WorkflowTriggerTaskStatus

Object

Server scripts

The status of an asynchronous workflow initiation task placed into the NetSuite task queue.

Method

task.checkStatus(options)

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.create(options)

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

task.ActionCondition

enum

Server scripts

Holds the string values for the possible record action conditions.

task.DedupeEntityType

enum

Server scripts

Holds the string values for entity types for which you can merge duplicate records with task.EntityDeduplicationTask.

task.DedupeMode

enum

Server scripts

Holds the string values for available deduplication modes when merging duplicate records with task.EntityDeduplicationTask.

task.MapReduceStage

enum

Server scripts

Holds the string values for the stages of a map/reduce script deployment, which is encapsulated by the task.MapReduceScriptTask object.

task.MasterSelectionMode

enum

Server scripts

Holds the string values for supported master selection modes when merging duplicate records with task.EntityDeduplicationTask.

task.TaskStatus

enum

Server scripts

Holds the string values for the possible status of tasks created and submitted with the N/task Module.

task.TaskType

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

CsvImportTask.submit()

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

CsvImportTask.id

string

Server scripts

The ID of the task.

CsvImportTask.importFile

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.

CsvImportTask.linkedFiles

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.

CsvImportTask.mappingId

number | string

Server scripts

Script ID or internal ID of the saved import map that you created when you ran the Import Assistant.

CsvImportTask.name

string

Server scripts

Name for the CSV import task.

CsvImportTask.queueId

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

CsvImportTaskStatus.status

string (read-only)

Server scripts

Status for a CSV import task. Returns a task.TaskStatus enum value.

CsvImportTaskStatus.taskId

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

EntityDeduplicationTask.submit()

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

EntityDeduplicationTask.dedupeMode

string

Server scripts

The mode in which to merge or delete duplicate records. Use values from the task.DedupeMode enum.

EntityDeduplicationTask.entityType

string

Server scripts

The type of entity on which you want to merge duplicate records. Use a task.DedupeEntityType enum to set the value.

EntityDeduplicationTask.id

string

Server scripts

The ID of the task.

EntityDeduplicationTask.masterRecordId

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.

EntityDeduplicationTask.masterSelectionMode

string

Server scripts

Master selection mode. Use values from the task.MasterSelectionMode enum.

EntityDeduplicationTask.recordIds

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

EntityDeduplicationTaskStatus.status

string (read-only)

Server scripts

Status for a merge duplicate record task. Returns a task.TaskStatus enum value.

EntityDeduplicationTaskStatus.taskId

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

MapReduceScriptTask.submit()

string

Server scripts

Submits a map/reduce script deployment for processing.

Property

MapReduceScriptTask.deploymentId

string

Server scripts

Script ID (as a string), for the script deployment record for a map/reduce script.

MapReduceScriptTask.id

string

Server scripts

The ID of the task.

MapReduceScriptTask.params

Object

Server scripts

Object that represents key-value pairs that override static script parameter field values on the script deployment record.

MapReduceScriptTask.scriptId

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

MapReduceScriptTaskStatus.getCurrentTotalSize()

number

Server scripts

Returns the total size in bytes of all stored work in progress by a task.MapReduceScriptTask.

MapReduceScriptTaskStatus.getPendingMapCount()

number

Server scripts

Returns the total number of records or rows not yet processed by the map stage of a task.MapReduceScriptTask.

MapReduceScriptTaskStatus.getPendingMapSize()

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.

MapReduceScriptTaskStatus.getPendingOutputCount()

number

Server scripts

Returns the total number of records or rows not yet processed by a task.MapReduceScriptTask.

MapReduceScriptTaskStatus.getPendingOutputSize()

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.

MapReduceScriptTaskStatus.getPendingReduceCount()

number

Server scripts

Returns the total number of records or rows not yet processed by the reduce stage of a task.MapReduceScriptTask.

MapReduceScriptTaskStatus.getPendingReduceSize()

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.

MapReduceScriptTaskStatus.getPercentageCompleted()

number

Server scripts

Returns the current percentage complete for the current stage of a task.MapReduceScriptTask.

MapReduceScriptTaskStatus.getTotalMapCount()

number

Server scripts

Returns the total number of records or rows passed as input to the map stage of a task.MapReduceScriptTask.

MapReduceScriptTaskStatus.getTotalOutputCount()

number

Server scripts

Returns the total number of records or rows passed as inputs to the output phase of a task.MapReduceScriptTask.

MapReduceScriptTaskStatus.getTotalReduceCount()

number

Server scripts

Returns the total number of record or row inputs to the reduce stage of a task.MapReduceScriptTask.

Property

MapReduceScriptTaskStatus.deploymentId

string (read-only)

Server scripts

Script ID for a script deployment record associated with a specific task.MapReduceScriptTask.

MapReduceScriptTaskStatus.scriptId

number (read-only)

Server scripts

Internal ID for a map/reduce script record associated with a specific task.MapReduceScriptTask.

MapReduceScriptTaskStatus.stage

string (read-only)

Server scripts

The current stage of a map/reduce script deployment that is being processed. See task.MapReduceStage for supported values.

MapReduceScriptTaskStatus.status

string (read-only)

Server scripts

Status for a map/reduce script task. Returns a task.TaskStatus enum value.

MapReduceScriptTaskStatus.taskId

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

QueryTask.addInboundDependency(options)

void

Server scripts

Adds a scheduled script task or map/reduce script task to the query task as a dependent task.

QueryTask.submit()

string

Server scripts

Submits the query task for asynchronous processing and returns the task ID.

Property

QueryTask.fileId

number

Server scripts

Internal ID of the CSV file to export query results to.

This property is mutually exclusive with the QueryTask.filePath parameter.

QueryTask.filePath

string

Server scripts

Path of the CSV file to export query results to.

This property is mutually exclusive with the QueryTask.fileId property.

QueryTask.id

string

Server scripts

The ID of the task.

QueryTask.inboundDependencies

Object[]

Server scripts

Key-value pairs that contain information about the dependent tasks added to the query task.

QueryTask.query

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

QueryTaskStatus.fileId

number (read-only)

Server scripts

Internal ID of the CSV file that query results are exported to.

QueryTaskStatus.query

query.Query (read-only)

Server scripts

Query definition for the submitted query task.

QueryTaskStatus.status

string (read-only)

Server scripts

Status of the submitted query task.

QueryTaskStatus.taskId

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

RecordActionTask.submit()

string

Server scripts

Submits a record action task for processing and returns its task ID.

Property

RecordActionTask.action

string

Server scripts

The ID of the action to be invoked.

RecordActionTask.condition

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.

RecordActionTask.id

string

Server scripts

The ID of the task.

RecordActionTask.paramCallback

Object

Server scripts

Function that takes record ID and returns the parameter object for the specified record ID.

RecordActionTask.params

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'}

RecordActionTask.recordType

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

RecordActionTaskStatus.complete

number (read-only)

Server scripts

The number of record action tasks with a completed status.

RecordActionTaskStatus.errors

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.

RecordActionTaskStatus.failed

number (read-only)

Server scripts

The number of record action tasks with a failed status.

RecordActionTaskStatus.pending

number (read-only)

Server scripts

The number of record action tasks with a pending status.

RecordActionTaskStatus.results

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.

RecordActionTaskStatus.status

string (read-only)

Server scripts

Represents the record action task status. Returns a value from the task.TaskStatus enum.

RecordActionTaskStatus.succeeded

number (read-only)

Server scripts

The number of record action tasks with a succeeded status.

RecordActionTaskStatus.taskId

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

ScheduledScriptTask.submit()

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

ScheduledScriptTask.deploymentId

string

Server scripts

Script ID (as a string), for the script deployment record associated with a task.ScheduledScriptTask object.

ScheduledScriptTask.id

string

Server scripts

The ID of the task.

ScheduledScriptTask.params

Object

Server scripts

Object with key-value pairs that override the static script parameter field values on the script deployment.

ScheduledScriptTask.scriptId

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

ScheduledScriptTaskStatus.deploymentId

string (read-only)

Server scripts

Script ID for a script deployment record associated with a specific task.ScheduledScriptTask object.

ScheduledScriptTaskStatus.scriptId

number (read-only)

Server scripts

Internal ID for a script record associated with a specific task.ScheduledScriptTask object.

ScheduledScriptTaskStatus.status

string (read-only)

Server scripts

Status for a scheduled script task. Returns a task.TaskStatus enum value.

ScheduledScriptTaskStatus.taskId

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

SearchTask.addInboundDependency()

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.

SearchTask.submit()

string

Server scripts

Places the asynchronous search initiation task into the SuiteScript task queue, and returns a unique ID for the task.

Property

SearchTask.fileId

number

Server scripts

ID of the CSV file to export search results into.

SearchTask.filePath

string

Server scripts

Path of the CSV file to export search results into.

SearchTask.id

string

Server scripts

The ID of the task.

SearchTask.inboundDependencies

Object[] (read-only)

Server scripts

Key-value pairs to describe the dependent scripts added to the search task.

SearchTask.savedSearchId

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

SearchTaskStatus.fileId

number (read-only)

Server scripts

ID of the CSV file into which search results are exported.

SearchTaskStatus.savedSearchId

number (read-only)

Server scripts

ID of the saved search executed during the task.

SearchTaskStatus.status

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.

SearchTaskStatus.taskId

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

SuiteQLTask.addInboundDependency(options)

void

Server scripts

Adds a scheduled script task or map/reduce script task to the SuiteQL task as a dependent task.

SuiteQLTask.submit()

string

Server scripts

Submits the SuiteQL task for asynchronous processing and returns the task ID.

Property

SuiteQLTask.fileId

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.

SuiteQLTask.filePath

string

Server scripts

Path of the CSV file to export SuiteQL query results to.

This property is mutually exclusive with the SuiteQLTask.fileId property.

SuiteQLTask.id

string

Server scripts

The ID of the task.

SuiteQLTask.inboundDependencies

Object[]

Server scripts

Key-value pairs that contain information about the dependent tasks added to the SuiteQL task.

SuiteQLTask.params

Array<string | boolean | number>

Server scripts

Parameters for the SuiteQL query.

SuiteQLTask.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

SuiteQLTaskStatus.fileId

number (read-only)

Server scripts

Internal ID of the CSV file that SuiteQL query results are exported to.

SuiteQLTaskStatus.params

Array<string | boolean | number> (read-only)

Server scripts

Parameters for the SuiteQL query.

SuiteQLTaskStatus.query

string (read-only)

Server scripts

SuiteQL query definition for the SuiteQL task.

SuiteQLTaskStatus.status

string (read-only)

Server scripts

Status of the SuiteQL task.

SuiteQLTaskStatus.taskId

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

WorkflowTriggerTask.submit()

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

WorkflowTriggerTask.id

string

Server scripts

The ID of the task.

WorkflowTriggerTask.params

Object

Server scripts

Object that contains key-value pairs to set default values on fields specific to the workflow.

WorkflowTriggerTask.recordId

number

Server scripts

Internal ID of the workflow definition base record. For example, 55 or 124.

WorkflowTriggerTask.recordType

string

Server scripts

Record type of the workflow base record. For example, customer, salesorder, or lead.

WorkflowTriggerTask.workflowId

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

WorkflowTriggerTaskStatus.status

string (read-only)

Server scripts

Status for a asynchronous workflow placed in the NetSuite task queue. Returns a value from the task.TaskStatus enum.

WorkflowTriggerTaskStatus.taskId

string (read-only)

Server scripts

The task ID associated with the specified task.

Related Topics

General Notices