CsvImportTask Object for Asynchronous CSV Imports in NetSuite

CsvImportTask enables automated, asynchronous CSV data imports into NetSuite, crucial for integration and scheduling.

·3 min read·View Oracle Docs

TL;DR Opening

The CsvImportTask object facilitates automated and asynchronous CSV imports into NetSuite, making it essential for developers who need to handle record data efficiently during SuiteApp installations, testing, or scheduled imports.

Overview of CsvImportTask Object

The CsvImportTask object is designed to manage CSV import tasks within NetSuite. This tool is pivotal for users who require automation and integration capabilities in their data handling processes. It supports various functionalities:

  • Automate imports for SuiteApps, demos, and tests.
  • Schedule imports using scripts.
  • Integrate with RESTlets for CSV importation.

Importing CSV Data with CsvImportTask

To effectively use the CsvImportTask, follow these steps:

  1. Set Up Import Mapping: Begin in the NetSuite UI by utilizing the Import Assistant, which helps define CSV mappings and options. It's critical to ensure that the necessary mapping is established, potentially using a sample file.

    • Gather script IDs for the import map.
    • Note any required linked files.
  2. Create the Task: Use the task.create(options) method to instantiate the CsvImportTask object.

  3. Configure Properties: Assign the appropriate import script and deployment properties to the CsvImportTask object.

  4. Submit the Task: Execute the CsvImportTask.submit() method to queue the task for processing.

  5. Check Status: Utilize the task.CsvImportTaskStatus properties to monitor the import's progress.

Import Limitations and Guidelines

While utilizing the CsvImportTask, keep in mind these essential guidelines:

  • Each import is bound to a limit of 25,000 records.
  • Data typically imported through (2-step) assistants in the UI cannot be handled by this object, as these imports do not allow saved mapping. This restriction includes certain record types, like budget entries and project tasks.
  • The CsvImportTask has access limited to saved field mappings and cannot utilize advanced options set in the Import Assistant, such as multi-threading. Regardless of prior settings, only a single thread and queue are employed for the submitted job.

Supported Script Types

The CsvImportTask is compatible with server scripts, which provides flexibility for backend processing.

Example Code

The following code demonstrates how to set up a CsvImportTask:

suitescript
1//Add additional code
2...
3var scriptTask = task.create({
4 taskType: task.TaskType.CSV_IMPORT
5});
6scriptTask.mappingId = 51;
7var f = file.load('SuiteScripts/custjoblist.csv');
8scriptTask.importFile = f;
9scriptTask.linkedFiles = {'addressbook': 'street,city\nval1,val2',
10 'purchases': file.load('SuiteScripts/other.csv')};
11var csvImportTaskId = scriptTask.submit();
12...
13//Add additional code

This sample provides the necessary syntax for creating and submitting a CSV import task. For complete script examples, refer to additional resources on the N/task module.

Related Topics

For further reading, consider exploring the following topics:

Key Takeaways

  • The CsvImportTask object simplifies asynchronous CSV imports into NetSuite.
  • Automation and scheduling features enhance data handling efficiency.
  • Be mindful of limitations regarding record counts and import mappings.

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

How do I set up import mapping for CsvImportTask in NetSuite?
To set up import mapping for CsvImportTask, use the Import Assistant in the NetSuite UI. Define CSV mappings and options, ensuring to gather script IDs for the import map and note any required linked files. This setup is crucial before creating and submitting a CsvImportTask.
What are the limitations of using CsvImportTask in NetSuite?
CsvImportTask has a record limit of 25,000 records per import. It cannot handle data typically imported through two-step assistants in the UI, such as budget entries and project tasks, due to a lack of saved mappings. Additionally, it cannot utilize advanced settings like multi-threading.
Can I use multi-threading with CsvImportTask?
No, CsvImportTask does not support multi-threading, even if previously set in the Import Assistant. The task will run using a single thread and queue.
What script types are supported by CsvImportTask in NetSuite?
The CsvImportTask is compatible with server scripts, allowing for flexible backend processing of CSV import tasks within NetSuite.
Source: Syntax 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 CSV Import

View all CSV Import articles →