Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to use issuekey in linkedIssues in the issue picker JQL?

I try to define an issue picker field. I would like to give the user the ability to select an issue, which is linked to the current issue. I tried the following JQL but it fails with an error:

project = "my project" AND issuetype = "my issue type" and issue in linkedIssues(issuekey, "my relation")

I get the error: Issue 'issuekey' can not be found.

The JQL does not evaluate the variable issuekey. Instead it takes the string 'issuekey' as the key.

How to fix this?

2 answers

2 votes

Scriptrunner issue picker JQL does not support (to the best of my knowledge) any placeholder to reference the current issue.

Any JQL you place there needs to be able to work exactly as is in a regular issue navigator screen.

The only way to get only the issues linked to the current issue is to use dynamic JQL.

Read more about this here:

But ultimately, what you need to do, is leave the JQL field empty in your picker configuration and instead add the following to the Configuration Scrip:

import com.atlassian.jira.issue.Issue

getJql = { Issue issue->
    """project = "my project" AND issuetype = "my issue type" and issue in linkedIssues(${issue.key}, "my relation")"""
0 votes

It's pretty clear that whatever you are using to call that JQL is not accepting the issuekey as a variable, so how are you calling that JQL? How are you parsing the query internally? How is the parameter being provided to the query string?

This is a Scriptrunner issue picker custom field. When you define such a custom field, you have to specify the JQL, which returns the list of issues, the issue picker displays to the user, in order to select one of them.

A custom field is an attribute of an issue. And the issuekey is also an attribute of an issue. I am expecting that an attribute value of an issue knows the issue it belongs to.

I still have no idea where you are defining this query. Are you implementing a searcher in custom plugin, something to do with java/api, or is it a completed plugin and you are trying to fill out some textbox with the query? Does the plugin allow variables at all?

If the case is you have some 3rd party plugin in front of you, you most probably are just entering a string into a text box. That's all it is in the background, just text.

It's up to the plugin to support any variables - which if it does, it should be documented and in which format. Probably something like {{issue.key}} or ${issue.key} or whichever else alternative - that's up to the plugin.

Can't tell without knowing which plugin it is - issue pickers are not out of box, and maybe your plugin does not allow variables at all.


I am expecting that an attribute value of an issue knows the issue it belongs to.

No, the attribute has no idea what issue it belongs to, it's just a simple key:value. The issue contains a reference to that particular attribute.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events