A special case of a web item creates a menu item that will open the Create Issue dialog with a predefined project, and optionally issue type.

This can be useful to workflow designers. Imagine a workflow where at one transition the user is required to create a new linked issue. Typically this is done by having a self or any to any transition which will created the linked issue with a post-function. Then the user is required to edit the linked issue further.

This built-in script removes this action from the workflow, and allows the linked issue to be edited in the create step.

Let’s go through an example. We’ll set up a web item which will open the Create Issue dialog to create a linked issue in another project:

create linked issue

Note the condition, which says that the link will be displayed only for one project, and a particular status.

We are placing the item in a new web section which we created in opsbar-operations.

We should see the link if the condition is fulfulled:

create blocking

Clicking the link should show the "new issue" dialog with the selected project and issue type prefilled:

create issue dialog

The problem here is that the issue won’t be linked automatically. The solution is integration with Behaviours.

Behaviours Integration

A Behaviour is required to pre-fill the Linked Issues field. We don’t want this behaviour to fire on every issue that it’s mapped to though. A behaviour script is able to get some information about how the create issue dialog was opened, which is the ID of the web item.

There are two API methods, that are available to all behaviours scripts, which facilitate this:


Gets the ID of the web item that was clicked, in the example above it would be link-create-blocking.


Gets the ID of the issue that was on the screen when the item was clicked.

With these we can create a behaviour, with the following initialiser function.

import com.atlassian.jira.component.ComponentAccessor

def issueManager = ComponentAccessor.getIssueManager()

if (getBehaviourContextId() == "link-create-blocking") {

    def contextIssue = issueManager.getIssueObject(getContextIssueId())

    getFieldById("summary").setFormValue("Issue created from ${contextIssue.key}").setReadOnly(true)
The behaviour must be mapped to the target project, but because you are checking the context ID, it won’t be fired when an issue is created in this project from the normal Create button.

This behaviour sets the link direction, and the linked issue. It also sets the summary and makes several fields read-only as you can see:

create issue linked

Creating a Subtask

You may wish to create a subtask of the current issue (or any other issue) at a particular stage.

We currently don’t have support via the UI for this (SRJIRA-2162). But you can do it with a raw XML fragment, with the caveat that the form will open in full-screen mode.

Reminder, pressing the Preview button generates the XML for any web fragment, which you can modify and submit via the raw xml module built-in script.

The XML to use is for example:

<web-item key='link-create-subtask' name='ScriptRunner generated web item - create-subtask' section='operations-operations' weight='1'>
    <label>Create Linked Subbie</label>
    <link linkId='link-create-constrained-subtask'>/jira/secure/CreateSubTaskIssue.jspa?parentIssueId=${issue.id}&amp;pid=${issue.projectObject.id}&amp;issuetype=10004</link>

Set the issue type ID of the subtask, and set the context path correctly. In the case of the example above it is /jira.

Further Community Examples:

For how-to questions please ask on Atlassian Answers where there is a very active community. Adaptavist staff are also likely to respond there.

Ask a question about ScriptRunner for JIRA, for for Bitbucket Server, or for Confluence.