runtime.executionContext

Note:

The content in this help topic pertains to SuiteScript 2.0.

Property Description

The execution context trigger of the current script.

Execution contexts provide information about how a 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. For more information, see Execution Contexts.

You can use the runtime.executionContext property to determine the execution context for a script and choose different logic depending on the context. Consider a script that applies to customer records and uses the beforeLoad(context) entry point. You may not want to execute this script when the entry point is triggered in response to a REST web services request. To prevent the script from executing in this context, you can do the following:

                    if (runtime.executionContext === runtime.ContextType.REST_WEBSERVICES) {
    return;
} 

                  

This property uses values from the runtime.ContextType enum.

Type

string (read-only)

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Script Types.

Module

N/runtime Module

Since

2015.2

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/runtime Module Script Samples.

          // Add additional code 
...
if (runtime.executionContext !== runtime.ContextType.USEREVENT)
    return;
...
// Add additional code 

        

Related Topics

N/runtime Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices