Hi,
I'm having issues while trying to create a quick filter for a board that would use `assignee = currentUser()` in ScriptRunner functions using JIRA Cloud.
The simplest possible way to reproduce the issue:
1. Create the following ScriptRunner function using an administrator account and save it. This function is supposed to show any issues that are parents of the currently logged in user.
`issueFunction in parentsOf("assignee = currentUser()")`
2. Create a quick filter for a board as `filter = myFilter`
This filter correctly returns parent issues for the administrator. However, for other accounts it still returns the parent issues for the same administrator instead of their own parent issues.
In another test, simple `assignee = currentUser()` ScriptRunner filter works fine in the same scenario.
Does it mean that there is a bug preventing `currentUser()` from being evaluated correctly when being nested in a ScriptRunner function?
Is there another way to achieve the same result?
Thanks
Hi Oksana,
I can confirm that unfortunately it is not possible to nest the currentUser() JQL function in the parentsOf() JQL function provided by ScriptRunner for Jira Cloud.
The reason for this is when you define the Enhanced Search that it searches as the last user who ran the search and then synchronizes the results back to the standard Jira Issue filter on the period that is defined in the Filter Sync Interval period on the Settings page as documented here.
This means when you reference this filter in a quick filter that the filter will only return the issues from the user who last ran the search on the Enhanced Search page and will not dynamically run the search for the current logged in user.
The only way to achieve your requirement is to have multiple enhanced search filters for each user where you hard code their accountId in the filter query and then have a separate quick filter for each user.
I hope this information helps.
Regards,
Kristian
Hi Kristian,
Thank you for your response to the OP as I found this reply when searching for a similar issue. I'll include my scripts below to share, but do you know if this core functionality has changed since your reply, allowing currentUser() to be nested in parentsOf() and not maintain the ID of the last user to run the search?
First query to look for open issues where the current user has a sub task, but is neither the assignee or the reporter of the issue (works great for the person who runs the search but includes the use of currentUser() inside parentsOf() function):
issueFunction in parentsOf("assignee = currentUser() AND statusCategory in (2, 4)") AND (assignee != currentUser() OR assignee = empty) AND (reporter != currentUser() OR reporter = empty)
Second query that uses the nested query above OR another string to find issues assigned to the current user (again, works great in practice for me but other users get my results when accessing the Kanbans and Dashboards that use this filter):
(filter = "<name of first query above>") OR (issuetype in standardIssueTypes() AND statusCategory in (2, 4) AND assignee = currentUser()) ORDER BY Rank ASC
Thank you for your time.
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.