Tips for SuiteScript Configuration and Code

There are many ways you can use SuiteScript when configuring and customizing your SuiteCommerce website. In addition to models and service controllers, you can also use scriptable cart, workflows, user events, and customized sales orders. If you want to take advantage of SuiteScript, you should understand and follow best practices to minimize potential performance problems that SuiteScript can introduce.

The information in the following sections is intended to help you ensure the scalability and performance of your website when using SuiteScript to implement the features you want.

Identify Performance Issues

One indicator of a performance issue is when a script takes a long time to run, but does not fail, resulting in web page latency. If you notice web page latency, a script is probably doing one or more of the following 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 a time limit for execution. This limit is not fixed and depends on the script type or application. If a single execution of a script or application takes longer than the time limit for its type, an SSS_TIME_LIMIT_EXCEEDED error is thrown. This error can also be caused by a script that is executed by another script, for example, from a user event script that is executed by a scheduled script.

SuiteScripts That Can Affect Performance

The following 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, consider the step in the process in which the latency is occurring because different types of customizations can 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

Configuration Best Practices

Changes in the NetSuite UI that determine how the script is run

Code-Level Best Practices

Changes to the general way you've written your script

Search Best Practices

Changes to the way you're searching for records or field data

Governance Best Practices

Changes to the resources your scripts are using, to avoid going over the usage limits

Standardization

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:

Related Topics

Best Practices for Commerce Websites
Configure Instead of Customize
Reports for Commerce Website Traffic
Manage and Maintain Images
Customize with Workflows
Marketing URL Parameters
Page Navigation and Redirection

General Notices