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,465,032
Community Members
 
Community Events
176
Community Groups

JIRA filter based on Role

Hi,

We need to be able to report on issues based on role. I must be missing something obvious here because I can't seem to find a way to do that.

What is the JQL for instance that returns all the Defects that are assigned to users in the Developers role?

Thanks,

Jozef 

 

6 answers

1 accepted

0 votes
Answer accepted
Randy Rising Star Jun 22, 2018

You cannot do this with JQL.

A workaround, if your role doesn't contain a ton of users is to generate a list of users from the role and include them explicitly in your query:

 

e.g.

assignee in (joe, jane, bob, betty, john, jill)

Thanks, Yes: we have tons of users in each role...

This can be done by using the projectsWhereUserHasRole() JQL function.

You'd have something like:

project in projectsWhereUserHasRole(Developers) and type = "Defect"

I use this syntax to filter issue based on roles in the project:

assignee in membersOfProjectRole("<project_name>", "<role_name>")

@Karmandroid Singularity It appears you have the cPrime plugin?

Here's another thought - not sure if it's what you want, but trying to help.

Set the conditions of a project workflow transition to filter issues based on Roles.  The person in a specific role is the only one who can see the transition.  Use a workflow post function to apply a specific label or set a custom field value.  Now, the issue is tagged by the Role of the person who transitioned it.  That tag (label/field) can be used as a condition to other workflow transitions and/or in a filter.

Because a workflow transition can end on the same status on which it began (loop transition), you can use a transition just to apply labels or set field values without actually transitioning the issue.  And once you've tagged them, other workflow conditions can make transitions available that weren't visible to untagged issues.  So, for example, a loop transition could apply a label "hardware" and a condition could check for that label, allowing only properly tagged issues to transition.

Another approach might be to create a custom user picker field that you assign based on some workflow condition.  It might start out as a copy of the Assignee field, but then get modified in a subsequent workflow transition.  With that custom user picker field limited to only the people that you want to have in it, you can build reports and filters using that field and know that it won't have "just anybody" in it.

Hope this helps.  And, yes, it would be better if Jira had the required logic to do this without such a circuitous workaround.

So far still no real default way to do this?

You can use the JQL Tricks add-on for this. See https://www.j-tricks.com/jqlt-user-functions.html for the available user functions.

usersInRole is the one you need.

Thanks, that plugin indeed comes with exactly the function we need. However, that costs more $s.

We have ScriptRunner. Do you know if this can be done using SR?

Randy Rising Star Jun 25, 2018

You can checkout the Scription JQL function support in SR.  I've never tried it but maybe the jiraUserPropertyEquals function will work.  There's a note in the doc that only admins can use it though...

 

https://scriptrunner.adaptavist.com/latest/jira/jql-functions.html#_user_functions

0 votes
miikhy Rising Star Jun 22, 2018

Hi Jozef,

As mentioned by @Randy, no native JQL for that. I would recommend either to name the users individually or to have groups assigned to Role and use:

type = Defect and assignee in membersOf("group-name")

Hope this helps!

Cheers

Thanks, but that would negate one of the advantages of using roles: that they can be maintained by a Project Administrator. Groups require JIRA admin access.

Bizarre JIRA does not have this function OOB, especially because of their push for the Project Administrators to take some of the load off of the JIRA Administrators.

Like # people like this

Suggest an answer

Log in or Sign up to answer