Localization Context Filtering for SuiteScript 2.x

Since 2020.1, you can define the localization context in which a client or user event script can execute. Localization context filtering allows you to execute a script based on the country associated with the active record or transaction and prevents scripts from executing unnecessarily. For a list of records and transactions that support localization, see Records that Support Localization Context.

You can specify the execution order of localized client and user event scripts. A maximum of 10 localized/non-localized client scripts are supported. For more information, see The Scripted Records Page.

The system automatically determines the localization context for records and transactions based on their values for country fields such as subsidiary and tax nexus. It is important to understand this determination before you set up localization context filtering for scripts. For details, see Determining the Localization Context.

The localization context feature includes:

The following table shows how you can specify the localization context based on the script type.

Script Type

Defining Localization Context Filtering

SuiteScript 2.0 Client Script Type

Complete the following steps to add localization context filtering to client scripts:

  1. Use the localizationContextEnter(scriptContext) and localizationContextExit(scriptContext) entry points in your script.

  2. Define the localization context on the Context Filtering tab on the script deployment record. For more information, see Localization Context.

SuiteScript 2.0 User Event Script Type

Define the localization context on the Context Filtering tab on the script deployment record only. For more information, see Localization Context.

If a script deployment is localized on the Context Filtering tab, the pageInit entry point of the script is ignored, and no other entry points of the script are called before localizationContextEnter or after localizationContextExit. It is possible that the record may never enter a localization context. In this case, no callbacks of the script are executed. For more information, see SuiteScript 2.x Client Script Entry Points and API.

Related Topics:

General Notices