The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Update Groups based on Checkboxes

pamela_ng
April 1, 2019

I have a list of multi-select checkboxes. The checked checkboxes will/should update a static Groups field.

I used the following code in Listener. This allows the Groups field to add the checked options in the checkboxes.

def groups = []
Issue issue = event.issue 
def teamsCheckboxesCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(12200L)
//find all values for checkboxes CF
def selectedValues = teamsCheckboxesCF.getValue(issue)*.value
log.warn(">>"+selectedValues)
selectedValues.each { value ->
def groupManager = ComponentAccessor.getGroupManager()
groups.add(groupManager.getGroup(value))
}
def changeHolder = new DefaultIssueChangeHolder()
def mv = new ModifiedValue(issue.getCustomFieldValue(teamsCF), groups)
teamsCF.updateValue(null, issue, mv, changeHolder)

However, when the checkbox is unchecked, the Group remained in the Groups field; it wasn't removed. Hope someone can help. Thanks!

0 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events