Binding variables

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 name Class Description
dbLookupTable GroovyLookupTable Accesses Lookup Tables, if any, that the script can access.
groovyCtxUtil GroovyCtxUtil Utility class for the ad-hoc data access.
groovyLogger GroovyLogger Use to log into a log file and display notifications in the GUI.
sessionLanguage String Current session's language code.
userInfo UserInfo Current 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.
curencyCollection CurrencyCollection Collection that stores all currency information, in the Plain Old Java Object (POJO) format.
uomCollection UnitOfMeasureCollection Stores 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());