Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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
4,555,754
Community Members
 
Community Events
184
Community Groups

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
AUG Leaders

Atlassian Community Events