Forums

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

Groovy code for defining a group field based on the reporter

Ankit Patel
Contributor
April 6, 2018

I looked around but am not able to find groovy for defining a group field to "X"if reporter is in that group. I have 3 groups and want to setup in a way that the correct group gets updated. none of the users are in multiple groups/.

1 answer

0 votes
Steven F Behnke
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.
April 6, 2018

"none of the users are in multiple groups"

That seems impossible.

 

Can you explain the use-case?

Ankit Patel
Contributor
April 6, 2018

@Steven F Behnke I re-read and agree it is confusing.  so here is what I am trying to do: 

I am working in JSD 3.9

I want to update the group field based on the reporter on a transition. 

The situation I am trying to work around is that for a workflow there are multiple teams working on it. Say X, Y, Z. and they go through multiple approvals to reach approved Status. when they reach this status, the queue fills up with all requests from X,Y,Z groups (I would like to separate those)

The queue I have built is not able to filter based on what the reporter's group is. So there is this custom field called"Assigned group" which is already being populated throughout the process. I want "Assigned Group"to update to either X or Y or Z when the issue transitions to Approved status based on who the reporter is.

I am using scriptrunner, but unable to get close to anything. This is what I have Come up with so far....

import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def groupManager = ComponentAccessor.getGroupManager()
def multiGroupCf = customFieldManager.getCustomFieldObjectByName("Assigned Group") //multigroup picker custom field

def X = groupManager.getGroup("X") //jira group
def Y = groupManager.getGroup("Y") //jira group
def Z = groupManager.getGroup("Z") //jira group
def groupList = [X, Y, Z]
issue.setCustomFieldValue(multiGroupCf, groupList)
Ankit Patel
Contributor
April 6, 2018

Hi Steven, 

 

I was able to set this up using queues, took a bit more of looking closely. 

Thanks for the quick response

Ankit

Suggest an answer

Log in or Sign up to answer