Using the Context Filtering Tab

In a script deployment record, the Context Filtering tab lets you specify the contexts in which a script will run. You can use context filtering to ensure that a script runs only when necessary, which can improve performance.

You can specify the execution context and localization context for a script:

The Script Deployment page Context Filtering tab.

You can use the N/recordContext module to get the context type for a record. For more information, see N/recordContext Module.

Execution Context

Execution contexts provide information about how or when a client script or user event script is triggered to execute. For example, a script can be triggered in response to an action in the NetSuite application, or an action occurring in another context, such as a web services integration. You can use execution context filtering to ensure that your scripts are triggered only when necessary. You can specify that a script should execute only in certain contexts, and this filtering can improve performance in contexts where the script is not required. For more information, see Execution Contexts.

On the Context Filtering tab of a script deployment record, you can select the contexts in which you want your script to execute. Your script will not execute if it is triggered in a context that is not selected. By default, all contexts are selected except for Web Application and Web Store. Often, it is not required to trigger scripts in these contexts, so they are disabled by default to improve performance. If you want your script to be triggered in these contexts, be sure to select them explicitly when you create your script deployment record.

To define the execution context:

  1. Define a new script deployment record or edit an existing one. For more information, see Script Deployment.

  2. In the script deployment record, click the Context Filtering tab. By default, all execution contexts are selected except for Web Application and Web Store.

  3. In the Execution Context field, select the contexts in which you want the script to execute. Cancel the selection of contexts in which the script should not execute.

  4. Click Save.

Localization Context

You can define the localization context in which a client or user event script can execute. You can enable the script execution for specific localization contexts programmatically and in the UI.

Localization filtering allows you to execute a script based on the country of the active record or transaction. For a list of records that support localization context, see Records that Support Localization Context.

NetSuite 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 more information, see Record 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.

You can also search for localized scripts by using the N/query Module. For more information, see N/query Module.

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

Script Type

Defining Localization Context Filtering

SuiteScript 2.x 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.

SuiteScript 2.x User Event Script Type

Define the localization context on the Context Filtering tab on the script deployment record only.

To define the localization context:

  1. Define or edit your script deployment record. For more information, see the help topic Use the Script Deployment Record.

  2. Click the Context Filtering tab. All countries are selected by default.

  3. Clear the Select All box.

  4. Click on the arrow button beside the Localization Context field.

    Localization Context with Select All field and down arrow highlighted.

    The Choose Localization Context popup window is displayed.

    Choose Localization Context window.
  5. Select a country. The selected country is automatically displayed under Current Selections.

  6. Click Done.

To avoid scrolling through a long list of countries, you can do any of the following:

  • The drop-down list on top of the popup window displays the pagination of the countries that are listed alphabetically. Select the pagination based on the first letter of the country that you want to specify and make your selection.

    Localization Context window with example of available countries.
  • Enter the country in the Search field and select it.

    Localization Context window with Search field highlighted.

Records that Support Localization Context

Transactions

Items

Entities

Others

Advanced Intercompany Journal Entry (advintercompanyjournalentry)

Assembly Item BOM (assemblyitembom)

Contact (contact)

Tax Type (taxtype)

Assembly Build (assemblybuild)

Description Item (descriptionitem)

Customer (customer)

Tax Code (salestaxitem)

Assembly Unbuild (assemblyunbuild)

Discount Item (discountitem)

Employee (employee)

Bin Transfer (bintransfer)

Download Item (downloaditem)

Generic Resource (genericresource)

Bin Worksheet (binworksheet)

Gift Certificate Item (giftcertificateitem)

Lead (lead)

Blanket Purchase Order (blanketpurchaseorder)

Item (item)

Other Name (othername)

Cash Refund (cashrefund)

Item Group (itemgroup)

Partner (partner)

Cash Sale (cashsale)

Kit Item (kititem)

Project (job)

Check (check)

Lot Numbered Build/Assembly Item (lotnumberedassemblyitem)

Project Template (projecttemplate)

Credit Card Charge (creditcardcharge)

Lot Numbered Inventory Item (lotnumberedinventoryitem)

Prospect (prospect)

Credit Card Refund (creditcardrefund)

Markup Item (markupitem)

Tax Group (taxgroup)

Credit Memo (creditmemo)

Non-Inventory Part (noninventoryitem)

Vendor (vendor)

Customer Deposit (customerdeposit)

Other Charge Item (otherchargeitem)

Customer Payment (customerpayment)

Payment Item (paymentitem)

Customer Payment Authorization (customerpaymentauthorization)

Sales Tax Item (salestaxitem)

Deposit (deposit)

Serialized Build/Assembly Item (serializedassemblyitem)

Deposit Application (depositapplication)

Serialized Inventory Item (serializedinventoryitem)

Customer Refund (customerrefund)

Service (serviceitem)

Estimate (estimate)

Shipping Item (shipitem)

Expense Report (expensereport)

Subscription Plan (subscriptionplan)

Fulfillment Request (fulfillmentrequest)

Subtotal Item (subtotalitem)

Intercompany Journal Entry (intercompanyjournalentry)

Intercompany Transfer Order (intercompanytransferorder)

Inventory Adjustment (inventoryadjustment)

Inventory Cost Revaluation (inventorycostrevaluation)

Inventory Count (inventorycount)

Inventory Status Change (inventorystatuschange)

Inventory Transfer (inventorytransfer)

Invoice (invoice)

Item Fulfillment (itemfulfillment)

Item Receipt (itemreceipt)

Journal Entry (journalentry)

Opportunity (opportunity)

Paycheck (paycheck)

Paycheck Journal (paycheckjournal)

Period End Journal (periodendjournal)

Purchase Contract (purchasecontract)

Purchase Order (purchaseorder)

Requisition (purchaserequisition)

Return Authorization (returnauthorization)

Revenue Arrangement (revenuearrangement)

Revenue Commitment (revenuecommitment)

Revenue Commitment Reversal (revenuecommitmentreversal)

Sales Order (salesorder)

Statistical Journal Entry (statisticaljournalentry)

Store Pickup Fulfillment (storepickupfulfillment)

Transfer Order (transferorder)

Vendor Bill (vendorbill)

Vendor Credit (vendorcredit)

Vendor Payment (vendorpayment)

Vendor Return Authorization(vendorreturnauthorization)

Work Order (workorder)

Work Order Close (workorderclose)

Work Order Completion (workordercompletion)

Work Order Issue (workorderissue)

General Notices