ANS-1061 · SUITESCRIPT DEVELOPMENT

Optimizing NetSuite Scheduled Scripts: Best Practices for Performance

Adhering to script execution limits and optimization guidelines is crucial for maintaining data integrity and preventing issues in NetSuite scheduled script deployments.

Short answer

To ensure reliable operation and prevent issues like duplicate processing, NetSuite scheduled scripts should be optimized to complete within recommended best practice times. While the system allows up to 60 minutes, aiming for shorter execution helps avoid conflicts with system restarts and maintenance, ensuring data integrity and efficient resource utilization.

Scenario

NetSuite scheduled scripts may occasionally crash or lead to duplicate record creation, such as invoices, if they exceed recommended execution times. This often occurs when scripts run concurrently with scheduled system events like JVM restarts or NetSuite patch fixes, leading to incomplete processes or unintended re-executions.

Solution

To prevent scheduled scripts from crashing or creating duplicate records due to conflicts with system restarts or NetSuite maintenance, it is essential to adhere to script optimization best practices and understand system execution limits. While SuiteScript 2.1 Scheduled Scripts have a system-imposed execution time limit of 60 minutes (3600 seconds), designing scripts for shorter durations is highly recommended.

Consider the following best practices for script optimization:

  1. Design user event scripts to execute in under 5 seconds.

  2. Design Suitelets and Portlets to execute in under 10 seconds.

  3. Design scheduled scripts to execute in under 5 minutes. This provides a sufficient margin of error to manage outlier use cases, such as unusually large data volumes or periods of high system load.

    To further mitigate risks associated with system restarts and patch fixes:

  4. Ensure scheduled scripts are optimized to complete well within the recommended 5-minute best practice, even though the system limit is 60 minutes.

  5. Consider rescheduling scripts to run at times that do not coincide with known NetSuite maintenance windows or scheduled system restarts.

Expert NetSuite Support

Need help with this NetSuite issue?

SuiteScript Development consulting and configuration support

Talk to a consultant