Tips for SuiteScript Configuration and Code
You can use SuiteScript in lots of ways when setting up and customizing your SuiteCommerce website. Besides models and service controllers, you can use scriptable cart, workflows, user events, and custom sales orders. If you want to take advantage of SuiteScript, you'll need to understand and follow best practices to avoid potential performance issues.
The next sections will help you keep your site scalable and high-performing when you use SuiteScript to add features.
Identify Performance Issues
One sign of a performance issue is when a script takes a long time to run but does not fail, causing web page latency. If you notice web page latency, a script's probably doing one or more of these tasks:
-
Performing a large number of record operations without going over the usage limit
-
Triggering a large number of additional user event scripts/workflows to execute
-
Performing a large number of database searches that take a long time to run
Each server-side script type or application has its own time limit for execution; it is not fixed and depends on the script type or application. If a script or application runs longer than its time limit, you'll get an SSS_TIME_LIMIT_EXCEEDED
error. This error can happen also when one script runs another; for example, a user event script triggered by a scheduled script.
SuiteScripts That Can Affect Performance
These types of scripts can potentially affect performance:
-
User event SuiteScripts deployed against sales orders, customer records, or forms used by the Commerce website
-
Workflows running against sales orders or customer records
-
Customized sales order records that have custom fields
-
Client SuiteScripts deployed against sales order records or forms used by the website (specifically cart and checkout performance when scriptable cart is enabled)
-
SuiteBundles that contain any of the preceding types of scripts
When analyzing a performance issue, think about where in the process the latency happens, since different customizations affect different areas. The following table summarizes the possibilities:
Step |
Scriptable Cart |
Customer User Event Scripts/Workflows |
Sales Order User Event Scripts/Workflows |
---|---|---|---|
Home Page |
|
|
|
Item List |
|
|
|
Add to Cart |
Yes |
|
|
View Cart |
|
|
|
Proceed to Checkout |
Yes |
|
|
Register/Login Page |
Yes |
Yes |
|
Add Address > Select Shipping Method |
Yes |
|
|
Select Shipping Method |
|
|
|
Add Payment Method > Review & Submit |
Yes |
|
|
Submit Order |
Yes |
|
Yes |
From the preceding table you can see that:
-
If you enable scriptable cart, it triggers on most pages throughout a shopper’s journey.
Scripts in SS/SSP files are often triggered on touchpoints, and Suitelet/RESTlet scripts can also be triggered on the website context.
-
Customer records and user event scripts can be triggered when the shopper logs in or registers a new account.
-
The moment a user submits an order, sales order user event scripts and workflows trigger, which can be problematic.
SuiteScript Best Practices for the Commerce Website Context
If you identify a potential performance issue, review the following best practices to learn about the types of changes that may help:
Area |
Description |
---|---|
Changes in the NetSuite UI that determine how the script is run |
|
Changes to the general way you've written your script |
|
Changes to the way you're searching for records or field data |
|
Changes to the resources your scripts are using, to avoid going over the usage limits |
|
Changes to the way you've implemented your script so that you use standard NetSuite functionality instead of your customization |
Additional SuiteScript Best Practices
For more detailed information about configuration, code-level, search, and other best practices when using SuiteScript to configure and customize your SuiteCommerce website, see the following topics: