The Adaptavist Group LogoDocumentation

Automatic Imports and Extension Methods

This page provides technical information on automatic imports and extension methods.

Automatic imports

For convenience, HAPI classes such as WorkItems, Users, and Spaces are automatically imported into all scripts compiled within ScriptRunner, so an explicit import is not required.

If you import another class called WorkItems it results in a conflict. To avoid conflicts, HAPI classes won't automatically import if there is an existing import for a class with the same name in a script.

For cases where you have a script that contains a conflicting import, you can access HAPI via the Hapi automatic import. This automatic import is unlikely to conflict with other classes. For example:

Hapi.workItems.create('ABC', 'Task') {
    summary = 'Hello world'
}

Extension methods

Extension methods are methods that ScriptRunner adds to classes that are not part of its own API, for instance, the Atlassian Jira API. In the following example, delete() is an extension method that is added by ScriptRunner.

def workItem = WorkItems.getByKey('ABC-1')

workItem.delete()

Other examples of extension methods include workItem .update(), user.delete() and group.add().

Search documentation

Start typing to search the docs.