Skip to main content

$jsapi.context

This method returns an object which represents the current request context.

tip
This is the same object as the one contained by the $context built-in JavaScript variable.

How to use

The $context variable is available from JavaScript code snippets under the script tag, but it cannot be referenced directly from files with the .js extension.

Use the $jsapi.context method so that external JavaScript files can access context variables such as $client, $session, and others.

function getName() {
return $jsapi.context().client.name;
}

function setName(newName) {
var $client = $jsapi.context().client;
$client.name = newName;
}