Localization Context Filtering for SuiteScript 2.x
You can set the localization context for client or user event scripts. Localization context filtering lets you run a script based on the country linked to the active record or transaction and keeps scripts from running when they aren't needed.. For a list of records and transactions that support localization, see Records that Support Localization Context.
You can set the order to run for localized client and user event scripts. NetSuite supports up to 10 localized or non-localized client scripts. For more information, see The Scripted Records Page.
NetSuite automatically determines the localization context for records and transactions using country fields like subsidiary and tax nexus. Make sure you understand how this works before setting up localization context filtering for scripts. For details, see Determining the Localization Context.
The localization context feature includes:
-
Localization Context Field — This field on the Context Filtering tab is part of the script deployment record. It lists the countries where the script is relevant. By default, all countries are selected. If you make a different selection, the script only runs on records linked to those countries.
-
Entry Points for Client Scripts — SuiteScript 2.0 client scripts have two entry points. You need these to use localization context filtering. localizationContextEnter(scriptContext) runs when the record enters the localization context that is specified on the script deployment record. localizationContextExit(scriptContext) runs when the record exits that context.
-
Locale Parameter —
scriptContext.locale
is parameter for the localizationContextEnter(scriptContext) and localizationContextExit(scriptContext) entry points. This parameter lists the countries representing the new localization context.
The table below shows how to set the lcoalization context for each script type.
Script Type |
Defining Localization Context Filtering |
SuiteScript 2.0 Client Script Type |
Follow these steps to add localization context filtering to client scripts:
|
SuiteScript 2.0 User Event Script Type |
Set the localization context on the Context Filtering tab of the script deployment record. For more information, see Localization Context. |
If you localize a script deployment on the Context Filtering tab, the pageInit
entry point is ignored, and no other entry points run before localizationContextEnter
or after localizationContextExit
. Sometimes, a record might never enter a localization context. For more information, see SuiteScript 2.x Client Script Entry Points and API.