SuiteScript 2.1 Server Scripts with Promises Overview
SuiteScript 2.1 introduces non-blocking asynchronous server scripts using promises, enhancing script performance for distinct operations.
Starting in NetSuite 2021.1, SuiteScript 2.1 enables developers to utilize non-blocking asynchronous server-side promises using the async, await, and promise keywords. This significant enhancement allows for greater efficiency and flexibility in script execution.
Key Modules Supporting Promises
The ability to use these keywords is restricted to a select group of modules:
N/httpN/httpsN/llmN/queryN/searchN/transaction
Error Handling for Unsupported Modules
It's crucial to note that using the async, await, or promise keywords in any other module API will result in an error. Developers must ensure that their scripts adhere to these limitations to avoid runtime issues.
Use Cases for Server-Side Promises
When implementing server-side promises, consider the following:
- In-Process Operations: This functionality is designed mainly for distinct in-process operations, such as executing specific business functions on a list of transactions where the order of execution does not matter.
- Not for Bulk Processing: It's important to understand that this capability is not intended for bulk processing scenarios, where out-of-band solutions like work queues might be more appropriate.
Conclusion
The introduction of promises in SuiteScript 2.1 dramatically enhances how developers can manage asynchronous operations on the server side. This feature is a valuable addition for developers looking to optimize their scripting workflows and improve performance.
Who This Affects
- Developers: Primarily those leveraging SuiteScript for server-side logic and operations.
- Administrators: Who may need to oversee and manage SuiteScript deployments in their organizations.
Key Takeaways
- SuiteScript 2.1 supports non-blocking async server-side promises.
- Usage is limited to specific modules to prevent errors.
- Ideal for in-process operations rather than bulk processing tasks.
Frequently Asked Questions (4)
What modules support using async and promises in SuiteScript 2.1?
What happens if I use async, await, or promise keywords in unsupported modules?
Is SuiteScript 2.1 suitable for bulk processing tasks with promises?
From which NetSuite edition is SuiteScript 2.1 with promises available?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
