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.

·2 min read·View Oracle Docs

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/http
  • N/https
  • N/llm
  • N/query
  • N/search
  • N/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.

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

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?
The supported modules for using async and promises in SuiteScript 2.1 are N/http, N/https, N/llm, N/query, N/search, and N/transaction.
What happens if I use async, await, or promise keywords in unsupported modules?
Using async, await, or promise keywords in unsupported modules will result in an error. It is important to restrict usage to the specified modules to avoid runtime issues.
Is SuiteScript 2.1 suitable for bulk processing tasks with promises?
No, SuiteScript 2.1's promise capabilities are not intended for bulk processing tasks. For such scenarios, out-of-band solutions like work queues are more appropriate.
From which NetSuite edition is SuiteScript 2.1 with promises available?
SuiteScript 2.1 with promises is available starting from the NetSuite 2021.1 release.
Source: SuiteScript 2.1 Server Scripts and Promises 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 General

View all General articles →