Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

IsInGroup with a custom field (ScriptRunner)

Михаил Дорохин May 29, 2018

Heya! 

So, how do I use IsInGroup to check if user in a custom field is in group?
I do know how to use it with that "Assignee" field, but not with a custom one.

import com.atlassian.jira.component.ComponentAccessor

def groupManager = ComponentAccessor.getGroupManager()

if ((groupManager.isUserInGroup(issue.assignee?.name, 'kanban_team_D'))) {
return("D");
} else if((groupManager.isUserInGroup(issue.assignee?.name, 'kanban_team_M'))) {
return("M");
} else if((groupManager.isUserInGroup(issue.assignee?.name, 'kanban_team_CRM'))) {
return("CRM")
} else {
return(":(")
}



1 answer

1 accepted

1 vote
Answer accepted
Alexey Matveev
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.
May 29, 2018

If your custom field is of the user picker type. then try to use like this

def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("field name")

groupManager.isUserInGroup(issue.getCustomFieldValue(cf)?.name, 'kanban_team_CRM')
Михаил Дорохин May 29, 2018

Сработало, спасибо!

Suggest an answer

Log in or Sign up to answer