Script Binding

When it is run, a script filter has access to all of the objects in its binding. A binding is a map of variable names to objects that are passed to the script engine and that can be accessed and modified (by name) from the script. This defines the API available to the script.

The objects in the binding are:

  • log—an object that can be called like a method and passed a string that will be logged by the filter. The output is logged in the application logs (with the name of the script name identifying the message) and is returned in the XML response to the filter results API call.
  • restClient—an instance of groovyx.net.http.RESTClient that can be used by the script to make REST calls to third party APIs. This object is specific to Groovy; it is more of a convenience for making REST calls.
  • socialContact—An object of type ScriptFilterSocialContact that has fields exposed. A copy of this object will be placed in the binding when the script is called. When the script exits, if the information in the copy has been modified, the SocialContact modifications are retained to the data store. The exposed fields are:
    • author
    • categories
    • description
    • * publishedDate
    • tags—Tags are of type List<String>. Duplicate tags are removed during the post-processing stages of the script engine.
    • title
    • * link
    • * sourceLink

Note that fields marked with * are read-only. Changes to these fields are not retained.

Filter processing is multi-threaded, the order is non-deterministic, and the campaign status is set after filtering is complete. For these reasons, the filterResults and campaignResults fields are omitted.