Context Objects in Entry Point and Custom Module Scripts

Every SuiteScript 2.1 script uses an entry point, whether it is an entry point script or a custom module script. Each entry point should correspond to an object defined in the script, which is usually a function. When it does, it is called an entry point function.

Most of the time, an entry point function gets access to an object provided by the system. This object lets your script access data and take actions based on the context where the script is running, which is why it's often called a context object.

Depending on what your script needs to do, this object can be a key part of your script. You can name it whatever you like, but most examples here call it context.

For more information about script types and entry points, see the SuiteScript 2.1 Script Types and Entry Points section under SuiteScript 2.1 Development Concepts.

Context Objects in Entry Point Scripts

Every standard script type has entry points specific to that type. Most of these entry points can access a context object that gives you data or methods. The properties of this object depend on the entry point you're using. For details about the context object for each entry point, check the documentation for that entry point.

For an example of how context objects work in a user event script, see SuiteScript 2.1 User Event Script Tutorial.

Context Objects in Custom Module Scripts

Similar to entry point scripts, a custom module script's entry point function can also get a context object. But in this case, the object isn't provided by NetSuite, but rather it comes from the SuiteScript that calls the module.

If you want a custom entry point function to get an object, the calling SuiteScript needs to be set up for that. The calling script has to create the object, set any needed properties, and pass it to the custom module script, which can then use it.

For an example, see SuiteScript 2.x Custom Module Tutorial.

To see how these components show up in scripts, check out SuiteScript 2.1 Anatomy of a Script and SuiteScript 2.x Anatomy of a Custom Module Script.

Related Topics

General Notices