Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×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:
Does anyone have any suggestions?
Edit: Added a mixed solution of using the scripted field and behavior. Is that the best solution?
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.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found a solution.
def MyKey = underlyingIssue?.key
getFieldByName("Picker").setConfigParam("currentJql", "<insert JQL here containing ${MyKey} to represent the current issue key>")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.