Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I use issue picker and only show issues within the project selected?

Edited

Context:

I am trying to recreate the "Epic Link" or "Component/s" or "Fix Version" like experience on a scripted field.

 

Docs: https://scriptrunner.adaptavist.com/5.5.0/jira/script-fields/issue-picker.html#_usage solves the first part of the experience below but not the second.

 

Experience:

As a user, I want to be able to start typing in something like "Foobar" and a list of issues that have "Foobar" in the text to start showing up in a drop down list (similar to the Epic Link experience and include the "None found" option), so that I can quickly find the issue I am looking for in the project.

As a user, I want to be able to restrict the search in the JQL by the current project (similar to the Component/s Fix Version functionality; most of the JQL search query examples have been "project = XXX"), so that I can only see the relevant issues to the specific project. 

As a user, I want to be able to see the key of the issue I selected in the field, so I know that I selected the correct issue. This would also allow it to show up as a free text searcher and in issue navigator.

 

Things I was thinking of:

project in projectMatch(<issueKey>) but I don't know how to extract that / if that would work. 

 

Semi okay experience:

project in recentProjects()

 

Some other documentation I have been researching:

https://scriptrunner.adaptavist.com/5.4.47/jira/recipes/misc/running-a-jql-query.html

https://scriptrunner.adaptavist.com/5.0.4/jira/scripted-fields.html#_jql_searches_in_script_fields

 

Potentially doing this and the top doc of issue picker may work:

https://community.atlassian.com/t5/Jira-Software-questions/How-to-restrict-a-project-picker-selection-list/qaq-p/799441

 

Does anyone have any suggestions?

 

Edit: Added a mixed solution of using the scripted field and behavior. Is that the best solution?

1 answer

1 accepted

2 votes
Answer accepted

After talking with @JamieA at Summit19 - he provided me with a solution.

 

Step 1:

Create the custom field with the issue picker: https://scriptrunner.adaptavist.com/5.5.0/jira/script-fields/issue-picker.html#_usage .

 

Step 2:

Create a behavior for all projects (or just the projects you care about) and potentially the issue types you care about.

Inside the initializer add:

getFieldByName("Picker").setConfigParam("currentJql", "project = ${issueContext.projectObject.key} and <insert the rest of your query>") 

 

Note: Unfortunately you have to hard code the query in both places. You technically don't need to hardcode it in step 1, but you should because of the second points below. 

Note: Unfortunately there isn't a "getConfigParam" to get the current JQL. I mentioned this to Jamie and he may fix it.

Note: Ideally issue picker would just support something like {issue.project.key} in the query. I mentioned this to Jamie and he may fix it.

Who is Jamie and is there a ticket to vote on that it really happens?

Like Erik Buchholz likes this

Jamie is/was one of the lead developers for Script Runner (he was the creator of it before it was bought out by Adaptavist). 

I don't know if there is a ticket for this, but the workaround above is still valid. Feel free to create a support ticket with Adaptavist and post it here (if they have a public tracker).

I would like to refer to the current issue, not the current project.

So I guess

project = ${issueContext.projectObject.key}

 should be replaced.

Could someone let me know what syntax to use?

I found a solution.

def MyKey = underlyingIssue?.key
getFieldByName("Picker").setConfigParam("currentJql", "<insert JQL here containing ${MyKey} to represent the current issue key>")
 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

How we use Jira Service Management for our recruitment process! - Part 2

It is never about setting up a process and being done with it. Rather, the focus should always be on optimizing it for the best outcomes. Thus, we didn’t stop at setting up JSM for our recruitment pr...

216 views 0 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you