Context Objects for Standard and Custom Entry Points

Every SuiteScript 2.x script needs to use an entry point, whether it's an entry point script or a custom module script. Each entry point should match up with an object you define in the script, which is usually a function. When it is, it's 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.

Note:

For more about entry points, see the Key SuiteScript 2.x Development Concepts section of SuiteScript 2.x Hello World.

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

Note:

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

Related Topics

General Notices