Fastrack issue based on creator and reporter (not) belonging to specific user group

Els Bassant
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2023

Hi Community, 

I'm trying to create a fast track issue post function with the following conditions:

  1. creator must be part of a specific group
  2. reporter must NOT be part of a specific group.

If both of these conditions are true then the issue skips the approval step.
If either of these conditions is false the approval will happen as normal.

 

Context:
We have some processes that need approval from a specific team. However, if users from that team create these requests on behalf of someone outside of the team the approval step may be skipped. If members of the team create a request for themselves, it will need approval as normally.

 

I've managed to get the first part working:

import com.atlassian.jira.component.ComponentAccessor

def groupManager = ComponentAccessor.getGroupManager()
groupManager.isUserInGroup(issue.creator, 'MyUserGroup')

 

But I'm not familiar with groovy scripting and don't know how to add the second condition.

Adding "currentUser != issue.reporter" works and will solve 90% of the use cases. But ideally I'd do this properly.

1 answer

1 accepted

1 vote
Answer accepted
Bobby Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2023

Hi @Els Bassant , 

You can store the results of both queries in variables and then perform an IF statement to return true or false based on your needs. So the code would look like this:

import com.atlassian.jira.component.ComponentAccessor

def groupManager = ComponentAccessor.getGroupManager()

def creatorInGroup = groupManager.isUserInGroup(issue.creator, 'Test Group 1')
def reporterInGroup = groupManager.isUserInGroup(issue.reporter, 'Test Group 1')


if(creatorInGroup && !reporterInGroup){
    return true
} else {
    return false
}

 

Let me know if this helps! 

Kind regards, 

Bobby

Els Bassant
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2023

This worked perfectly, thank you!

Like Bobby Bailey likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events