Binding variables
  • 30 Apr 2024
  • 1 Minute to read
  • Dark
    Light

Binding variables

  • Dark
    Light

Article summary

Depending on the extension point, some variables are automatically made available inside the script. These are called binding variables.

Some binding variables are available to all scripts; others are available only to specific extension points. For example, extension points related to quotes automatically include a variable named salesItemsTree, which represents the quote's data. Scripts can use this variable to query information or make changes to a quote and its sales items.

Common binding variables

The following table lists binding variables available to each extension point.

Variable nameClassDescription
dbLookupTableGroovyLookupTableAccesses Lookup Tables, if any, that the script can access.
groovyCtxUtilGroovyCtxUtilUtility class for the ad-hoc data access.
groovyLoggerGroovyLoggerUse to log into a log file and display notifications in the GUI.
sessionLanguageStringCurrent session's language code.
userInfoUserInfoCurrent user's basic information. This variable is null if the script is not triggered during a particular user's session, such as when triggered by a scheduled system task.
curencyCollectionCurrencyCollectionCollection that stores all currency information, in the Plain Old Java Object (POJO) format.
uomCollectionUnitOfMeasureCollectionStores all unit of measure information, in the POJO format.

Query a script for available binding variables

You can query a script for a list of its available binding variables.

For example, the following script obtains the classes and names of all available binding variables and outputs the result to a notification message.

def sb = new StringBuilder();
binding.variables.each {
    sb.append('(' + it.value.getClass().getName() + ') ')
        .append(it.key)
        .append("\n");
}
groovyLogger.notifyInfo(sb.toString());

Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.