Hi Community,
I'm trying to create a fast track issue post function with the following conditions:
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.
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
This worked perfectly, thank you!
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.