Configuration Best Practices

Read the following sections to learn how to effectively configure scripts for your Commerce website.

Prevent a Script from Running in the Web Store Context

If a script is only required when orders are being placed in the backend (for example, by staff members), then you can disable it from running on the frontend.

  1. Go to Customization > Scripting > Script Deployments.

  2. Select the Edit option for the script you want to modify.

  3. On the Script Deployment page, select the Audience tab.

  4. In the Roles dropdown list, disable the Select All checkbox.

  5. In the Employees dropdown list, enable the Select All checkbox.

For user event scripts, there is another setting you can modify if your script is not needed on the frontend.

  1. Go to Customization > Scripting > Script Deployments.

  2. Select the Edit option for the script you want to modify.

  3. On the Script Deployment page, disable the Execute in Commerce Context checkbox.

    When this checkbox is enabled, the script executes on SuiteCommerce, SuiteCommerce Advanced, and SuiteCommerce InStore sites. When this checkbox is disabled, the script is prevented from running in that context.

Prevent a Workflow from Running in the Web Store Context

If a particular workflow is not needed on the frontend, you can edit the settings to prevent it from running in the web store context.

  1. Go to Customization > Workflow > Script Workflows.

  2. Select the Edit option for the workflow you want to modify.

  3. In the Summary for the workflow, click the pencil icon to edit the workflow settings.

  4. In the Event Definition settings, find the Contexts dropdown list and clear the Web Store option.

Specify a Script’s Execution Context

You can use the Event Type dropdown on Suitlet, user event, and record-level client script deployment pages to specify a script’s execution context at the time of deployment. When you specify the event type, the script only executes on that event, regardless of what is specified in the script itself.

  1. Go to Customization > Scripting > Script Deployments.

  2. Select the Edit option for the script you want to modify.

  3. From the Event Type dropdown list, select the event type that should trigger the script.

The event type option you choose in the script deployment page takes precedence over an event type specified in the script file. For example, if you specify the Create event type in the script file and then select Delete in the dropdown list, the script is restricted from running in any event other than Delete.

If you leave the Event Type dropdown list empty, the script runs in the event types specified in the script.

Use Asynchronous afterSubmit User Events

If you do not enable asynchronous execution, your script is processed synchronously. With synchronous execution the system waits for the entire script to run before proceeding, blocking the user. If you enable asynchronous execution, normal processes complete while your script runs in the background. Consider using asynchronous execution if the outcome of your script doesn't impact the submission of the record or order. For more information, see Promise Object.

Related Topics

Tips for SuiteScript Configuration and Code
Code-Level Best Practices
Search Best Practices
Governance Best Practices
Standardization

General Notices