module function · N/task
create()
task.create(options)
Creates an object for a specific task type and returns the task object.
- Implementation
- Not started
- Design
- Open for proposals suggest how it should read
A
suitescript api
1task.create({2 taskType: /* string, required */,3 params: /* Object | Array<string | boolean | number>, optional */,4 scriptId: /* number | string, optional */,5 importFile: /* file.File | string, optional */,6 linkedFiles: /* Object, optional */,7 mappingId: /* number | string, optional */,8 name: /* string, optional */,9 queueId: /* number, optional */,10 dedupeMode: /* string, optional */,11 entityType: /* string, optional */,12 recordIds: /* number[], optional */,13 recordId: /* number, optional */,14 recordType: /* string, optional */,15 workflowId: /* number | string, optional */,16 fileId: /* number, optional */,17 filePath: /* string, optional */,18 query: /* query.Query | string, optional */19});
| Parameter | Type | Required | Description |
|---|---|---|---|
| options.taskType | string | required | The type of task object to create. Use the task.TaskType enum to set the value. |
| options.params | Object | Array<string | boolean | number> | optional | An object that represents additional parameters and values for the task. This parameter accepts different values based on the value of the options.taskType parameter: If options.taskType is set to task.TaskType.SCHEDULED_SCRIPT , task.TaskType.MAP_REDUCE or task.TaskType.WORKFLOW_TRIGGER , this parameter accepts key-value pairs that override static script parameter field values on the script deployment record. For more information, see Creating Script Parameters Overview . For workflow tasks, keys can include fields on the Workflow Definition Page , or workflow and state custom fields. For more information, see Workflow Custom Fields . If options.taskType is set to task.TaskType.SUITE_QL , this parameter accepts an array of parameters for the associated SuiteQL query. The specified parameters are substituted into the SuiteQL query string when you submit the task. This parameter sets the value for the ScheduledScriptTask.params , MapReduceScriptTask.params , WorkflowTriggerTask.params , or SuiteQLTask.params properties. This parameter is applicable only when options.taskType is set to task.TaskType.SCHEDULED_SCRIPT , task.TaskType.MAP_REDUCE , task.TaskType.WORKFLOW_TRIGGER , or task.TaskType.SUITE_QL . |
| options.scriptId | number | string | optional | The internal ID (as a number) or script ID (as a string) for the script record. This parameter sets the value for the ScheduledScriptTask.scriptId or MapReduceScriptTask.scriptId property. This parameter is applicable only when options.taskType is set to task.TaskType.SCHEDULED_SCRIPT or task.TaskType.MAP_REDUCE . |
| options.importFile | file.File | string | optional | A CSV file to import. Use a file.File object or a string that represents the CSV text to be imported. This parameter sets the value for the CsvImportTask.importFile property. This parameter is applicable only when options.taskType is set to task.TaskType.CSV_IMPORT . |
| options.linkedFiles | Object | optional | 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. The key is the internal ID of the record sublist for which data is being imported and the value is either a file.File object or the raw CSV data to import. You can assign multiple types of values to this property. This parameter sets the value for the CsvImportTask.linkedFiles property. This parameter is applicable only when options.taskType is set to task.TaskType.CSV_IMPORT . |
| options.mappingId | number | string | optional | The internal ID (as a number) or script ID (as a string) of a saved import map created using the Import Assistant. See task.CsvImportTask . This parameter sets the value for the CsvImportTask.mappingId property. This parameter is applicable only when options.taskType is set to task.TaskType.CSV_IMPORT . |
| options.name | string | optional | The name for the CSV import task. You can optionally set a different name for a scripted import task. In the UI, this name appears on the CSV Import Job Status page. This parameter sets the value for the CsvImportTask.name property. This parameter is applicable only when options.taskType is set to task.TaskType.CSV_IMPORT . |
| options.queueId | number | optional | Overrides the Queue Number property under Advanced Options on the Import Options page of the Import Assistant. Use this property to programmatically select an import queue and improve performance during the import. Note: This property is only available if you have a SuiteCloud Plus license. For more information about using multiple queues when importing CSV files, see Queue Number and Use Multiple Threads and Multiple Queues to Run CSV Import Jobs . This parameter sets the value for the CsvImportTask.queueId property. This parameter is applicable only when options.taskType is set to task.TaskType.CSV_IMPORT . |
| options.dedupeMode | string | optional | Sets the mode for merging or deleting duplicate records. This parameter sets the value for the EntityDeduplicationTask.dedupeMode property. This parameter is applicable only when options.taskType is set to task.TaskType.ENTITY_DEDUPLICATION . Use the task.DedupeMode enum to set the value. |
| options.entityType | string | optional | Sets the type of entity on which you want to merge duplicate records. This parameter sets the value for the EntityDeduplicationTask.entityType property. This parameter is applicable only when options.taskType is set to task.TaskType.ENTITY_DEDUPLICATION . Use the task.DedupeEntityType enum to set the value. Note: If you specify a value of CUSTOMER for this parameter, NetSuite automatically includes prospects and leads in the task request. |
| options.recordIds | number[] | optional | The internal IDs of the records to perform the merge or delete operation on. You can use the search.duplicates(options) method to identify duplicate records or create an array with record internal IDs. This parameter sets the value for the EntityDeduplicationTask.recordIds property. This parameter is applicable only when options.taskType is set to task.TaskType.ENTITY_DEDUPLICATION . |
| options.recordId | number | optional | The internal ID of the base record. This parameter sets the value for the WorkflowTriggerTask.recordId property. This parameter is applicable only when options.taskType is set to task.TaskType.WORKFLOW_TRIGGER . |
| options.recordType | string | optional | The record type of the workflow definition base record, such as customer, salesorder, or lead. In the Workflow Manager, this is the record type that is specified in the Record Type field. This parameter sets the value for the WorkflowTriggerTask.recordType property. This parameter is applicable only when options.taskType is set to task.TaskType.WORKFLOW_TRIGGER . |
| options.workflowId | number | string | optional | The internal ID (as a number) or script ID (as a string) for the workflow definition. This is the ID that appears in the ID field on the Workflow Definition Page . This parameter sets the value for the WorkflowTriggerTask.workflowId property. This parameter is applicable only when options.taskType is set to task.TaskType.WORKFLOW_TRIGGER . |
| options.fileId | number | optional | The internal ID of the CSV file to export search results to. For more information about working with files, see N/file Module . This parameter is mutually exclusive with the options.filePath parameter. If you specify values for both parameters, an error occurs. This parameter sets the value for the SearchTask.fileId , QueryTask.fileId , or SuiteQLTask.fileId properties. This parameter is applicable only when options.taskType is set to task.TaskType.SEARCH , task.TaskType.QUERY , or task.TaskType.SUITE_QL . |
| options.filePath | string | optional | The path of the CSV file to export search results to. For more information about working with files, see N/file Module . This parameter is mutually exclusive with the options.fileId parameter. If you specify values for both parameters, an error occurs. This parameter sets the value for the SearchTask.filePath , QueryTask.filePath , or SuiteQLTask.filePath properties. This parameter is applicable only when options.taskType is set to task.TaskType.SEARCH , task.TaskType.QUERY , or task.TaskType.SUITE_QL . |
| options.query | query.Query | string | optional | The query definition for a query task or SuiteQL task. This parameter accepts different values based on the value of the options.taskType parameter: If options.taskType is set to task.TaskType.QUERY , this parameter accepts a query.Query object that represents the query to run. If options.taskType is set to task.TaskType.SUITE_QL , this parameter accepts a string that represents the SuiteQL query to run. This parameter sets the value for the QueryTask.query or SuiteQLTask.query properties. This parameter is applicable only when options.taskType is set to task.TaskType.QUERY or task.TaskType.SUITE_QL . |
B
mynt syntax
No Mynt syntax yet.
Nothing in the language compiles to task.create(options) today. How should it read?
C
community proposals
Competing syntax for create, from GitHub Discussions. Select two or more to compare them side by side.
Loading proposals from GitHub…
D
suggest an alternative
Write the Mynt you wish you could write.
A good proposal shows the syntax, the SuiteScript it should become, and argues for it: why it is clearer, how it fits the rest of the language, what it makes harder.
- Clarity. Does it say what happens, without ceremony?
- Consistency. Does it read like
load,saveandRef[field]? - Expressiveness. Does it cover the cases people actually write?
- Honesty. Does it hide a NetSuite cost, such as governance, that a reader should see?