A field that allows for picking an issue, or issues, from a pre-defined JQL query. Examples for usage might be:

This is similar to a standard issue link, but has some advantages, and disadvantages, versus an issue link.

A disadvantage of using this field is that there is no reciprocal link available currently. In order to find issues linking to an issue you would need to execute a JQL query.

Usage

Create a new field via Admin → Script Fields. Note that although you can create these types of field via Admin → Custom Fields, you cannot configure them there so it is easier to do it through the ScriptRunner interface.

create issue picker

You can preview the result…​ but note that if you are previewing before creating the field, you will not be able to see a preview of the view output as no issue will have a value for this field. Previewing is useful to verify that the picker is only displaying the correct candidate issues.

After creating the field ensure it has the correct context and the correct screens.

issue picker usage

You can create additional field configurations for this field, with different project/issue type contexts…​ you can then modify the parameters such as the JQL query, but the plurality of the field must remain the same, you cannot have different contexts where you have a mix of single and multiple pickers.

Searching

You can search for issues linking to a particular issue, example:

"Related Problem" = "MSD-5"
"Related Problem" in ("MSD-5", "MSD-6")

You can also use the IN, !=, NOT IN operators, or the basic search mode.

Programmatic Updates

Creating an issue using IssueService:

def issueService = ComponentAccessor.issueService
def issueInputParameters = issueService.newIssueInputParameters()

issueInputParameters.addCustomFieldValue(fieldId, "MSD-5")

If you retrieve or set the value directly on the issue, the result will be an Issue object, or if you have chosen a multiple issue picker, a Collection<Issue>.

// single issue picker
assert issue.getCustomFieldValue(customField) instanceof Issue

// multiple issue picker
assert issue.getCustomFieldValue(customField) instanceof Collection
assert issue.getCustomFieldValue(customField).every {it instanceof Issue}

REST

Setting a multiple issue picker:

fields: {
    customfield_12345: ["MSD-5", "MSD-6"]
}

Adding to a multiple issue picker:

update: {
    customfield_12345: [
        {"add" : "MSD-5"}
    ]
}

Etc.

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.