Basics

SuiteScript Governance

Understanding Governance

SuiteScript governance limits API usage to prevent performance issues.

What is SuiteScript Governance?

SuiteScript Governance is a set of rules and limits implemented by NetSuite to ensure that scripts run efficiently and do not negatively impact system performance. It essentially prevents any single script from monopolizing resources, ensuring fair usage across all scripts and users.

Why Governance Limits Matter

Governance limits are crucial because they help balance the load on NetSuite's servers, preventing performance degradation. This is particularly important in a multi-tenant environment where multiple users and scripts operate concurrently.

Types of Governance Limits

NetSuite enforces several types of governance limits, primarily focusing on API usage. Some key areas include:

  • API Request Limits: These limit the number of requests a script can make to the NetSuite APIs.
  • Execution Time Limits: These restrict the amount of time a script can run.
  • Memory Usage Limits: These cap the amount of memory a script can consume.

Governance Points System

Each SuiteScript 2.0 script operation consumes a certain number of governance points. The total points a script consumes must not exceed a predefined limit, which varies depending on the script type. Exceeding these limits will result in a runtime error.

Handling Governance Limits in Scripts

To handle governance limits effectively, developers should:

  • Monitor Usage: Use logging to track governance points usage and identify bottlenecks.
  • Optimize Code: Refactor scripts to be more efficient, reducing the number of API calls and execution time.
  • Batch Processing: Break down large tasks into smaller, manageable batches to avoid hitting limits.

Example: Checking Governance Points Usage

Here's a simple example of how to check and log governance points usage in a SuiteScript 2.0 script:

Best Practices for Managing Governance Limits

To stay within governance limits, consider the following best practices:

  • Avoid Unnecessary API Calls: Retrieve only the data you need.
  • Schedule Scripts During Off-Peak Hours: This can help manage load and ensure smoother execution.
  • Use Efficient Data Structures: Choose data structures that minimize memory usage.
Previous
Modules