Discover how N/task module in SuiteScript facilitates creating tasks for internal NetSuite scheduling, executing scripts, importing CSV files, and more, crucial for seamless integration.
N/task module is a cornerstone of SuiteScript, enabling developers to create tasks and place them in the internal NetSuite scheduling or task queue. These tasks serve a variety of purposes, including submitting scheduled scripts, running map/reduce scripts, importing CSV files, merging duplicate records, and executing asynchronous saved searches, constructed queries, SuiteQL queries, and workflows. Here, we delve into two task types that have been integral to our integration:
The CSVImport Task is a powerful tool integrated into SuiteScript, allowing developers to import CSV files into NetSuite. This task, when added to the task queue, asynchronously imports data into NetSuite. It's a versatile way to read and process CSV data within scripts. Notable details about the CSVImport Task include:
a. Efficient Data Import: Developers can employ the CSVImport Task to streamline the process of importing CSV data into NetSuite.
b. File Mapping with Import Maps: NetSuite's Import Assistant provides a UI tool for mapping CSV fields to NetSuite’s records and their fields and saving these mappings as Import Maps. Each Import Map is assigned a unique ID , which can be utilized by developers in SuiteScript. This unique identifier plays a pivotal role in mapping the fields of a CSV file to the corresponding fields within NetSuite records. ImportMapID ensures that data is seamlessly transposed from the CSV format to the structure required by NetSuite, simplifying the integration process and ensuring data accuracy.
c. Limitation: It's important to note that the CSV Import Assistant supports most commonly imported record types, but it does not support certain record types, such as Shipment Receipts and Customer Order Fulfillment. For information about the record types supported by the Import Assistant, please refer to Supported Record Types for CSV Import.It's important to note that CSV imports performed within scripts are subject to NetSuite's application limit of 25,000 records.
The Search Task is similar to NetSuite's Saved Search, with additional features that enable developers to not only conduct searches, but also persist the results and store them in NetSuite File Cabinet. This capability proves invaluable when dealing with searches across high volumes of data. Key insights into the Search Task include:
High-Speed Searches: The Search Task is optimized for speed, making it highly efficient for synchronizing large volumes of data.
Versatile Use: Developers can use SavedSearchIDs to execute specific searches, similar to Saved Searches.
Efficient Data Export: The task fetches the results of the saved search and exports them to a CSV file and automatically puts it in the Netsuite File Cabinet at very fast speed.
Advantages: It offers several advantages, including a simplified and efficient way to execute searches and export data. Compared to methods like using Map/Reduce script, it has shown impressive performance improvements, notably in scenarios involving the export of large datasets. We will discuss this further in which scenarios we have used this in our integration.
Discover the power of N/Search module in SuiteScript, enabling dynamic data retrieval from NetSuite database with custom filters and conditions, enhancing integration capabilities.
The N/Search module plays a pivotal role in our integration strategy, significantly enhancing our data retrieval capabilities. This module empowers developers to query data from the NetSuite database, offering the flexibility to create new searches programmatically, with filters and conditions. When conducting dynamic searches, the N/Search module generates a new dynamic SavedSearchId, which can be reused in subsequent processes.
Furthermore, developers can also harness existing SavedSearchIds created through NetSuite's user interface.
Explore how the N/Record module in SuiteScript facilitates seamless data integration by working with NetSuite records, including those not supported by NetSuite's CSV import.
The N/Record module serves as a pivotal tool in our integration strategy for working with NetSuite records. It is notably advantageous when handling data not natively supported by NetSuite's CSV import functionality. For instance, NetSuite may not support the direct import of certain records, such as Shipment Receipts created in HotWax Commerce.
In such scenarios, we employ the N/Record module to bridge this gap. By writing SuiteScript, we can read CSV data from files located in SFTP locations, iterate through each record, and seamlessly create records in NetSuite's database. This process ensures the effective import of data into NetSuite for records that fall outside the scope of CSV Import methods.
Moreover, the N/Record module extends its capabilities to include the creation, deletion, copying, loading, or modification of standard NetSuite records. This versatile module plays a central role in our integration, facilitating the manipulation of native NetSuite records to achieve seamless data synchronization.
Leverage the N/file module in SuiteScript for seamless file management, enabling easy upload and efficient reading of files from NetSuite File Cabinet or SFTP.
The N/file module broadens our capabilities by enabling interaction with files within NetSuite. This module allows us to upload files to and read files from the NetSuite File Cabinet or SFTP. Key functionalities of the N/file module include:
File Upload: Easily upload files to the NetSuite File Cabinet, making them accessible within the NetSuite environment.
File Reading: Reading files from the NetSuite File Cabinet or SFTP is a streamlined process with the N/file module, facilitating efficient data retrieval.
Discover how HotWax Commerce leverages SuiteScript for seamless integration with NetSuite, using JavaScript-based customization, scheduled scripts, and data transformation.
NetSuite's SuiteScript is a scripting language that acts as a pivotal tool for customization and automation. It provides comprehensive application-level scripting capabilities that span both client and server sides. In our integration with NetSuite, HotWax Commerce leverages SuiteScript 2.X APIs.
It's worth noting that while NetSuite boasts a plethora of integration tools, our focus here is specifically on those that have played a pivotal role in our integration. Below, we offer an in-depth understanding of SuiteScript 2.X and how it has been instrumental in our integration:
JavaScript-Based Customization: SuiteScript is grounded in JavaScript, offering developers the ability to craft custom scripts and functions within the NetSuite environment. These scripts can be invoked manually, triggered by specific events, or on a pre-defined schedule enabling profound customization possibilities.
Scheduled Scripts: An essential feature of SuiteScript is the ability to schedule scripts for future execution. Tasks can be submitted for processing at specific times or on a recurring basis, providing a powerful tool for automation and data handling.
Data Transformation: Developers can use SuiteScript to transform NetSuite data into different formats and structures. This flexibility ensures that data can seamlessly flow between systems or be presented in a manner that suits the specific needs of the integration.
File Operations: SuiteScript extends its reach beyond NetSuite, enabling the reading or writing of files in various formats from external SFTP locations. This functionality plays a crucial role in the exchange of data between systems. We will discuss further on how developers can use file operations in Suite Script.
Netsuite supports multiple types of Suite Scripts. We have used two types of scripts in our integration. They are:
Scheduled Script: Scheduled scripts can be run on demand or at predefined intervals on a recurring basis. They are best suited for handling basic information logging or similar tasks. However, they are not well-suited for processing large amounts of records or long-running operations.
Map/Reduce Script: Map/reduce scripts can also be run on demand or at predefined intervals on a recurring basis however they are designed to handle large volumes of data. They are most effective when data can be divided into smaller, independent parts. Map/reduce scripts are well-suited for scenarios where multiple records need processing, and the logic can be divided into lightweight segments.
Unlocking SuiteScript Capabilities
Modules are at the core of what allows developers to work with NetSuite. Without modules, there would be no such thing as SuiteScript 2.0. SuiteScript 2.0 follows a modular approach by organizing its APIs into standard modules. This modular approach enhances code reusability and maintainability, ensuring that each script loads only the necessary modules.
Modules contain the API information needed for scripting. There are multiple modules to perform various tasks in NetSuite Suite Script, and in our integration strategy, we have focused on key modules that align with our objectives. We have documented a few of the significant modules that have played a pivotal role in our integration.
These four modules together form the core of our SuiteScript-based integration, offering a comprehensive set of tools to address various aspects of our integration strategy. The strategic selection of modules, including N/task, N/Record, N/Search, and N/file, has played a pivotal role in our integration success, ensuring that our objectives are met efficiently and effectively.
Task Module
Record Module
Search Module
File Module