Groovy Code Setting a multi group picker custom field based on value of cascading select list value

We are trying to set a group picker (multiple groups) custom field (Stage Approver) using custom script post function.

Here is the script I am using. It is working for updating single group. Multiple groups is not working . Could anyone please guide me on this ?

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def groupManager = ComponentAccessor.getGroupManager()

def multiGroupCf = customFieldManager.getCustomFieldObjectByName("Stage Approver") //multigroup picker custom field

def TeamDatagroup = groupManager.getGroup("TeamData Approvers") //jira group
def BOgroup = groupManager.getGroup("Business Owners") //jira group

issue.setCustomFieldValue(multiGroupCf, [TeamDatagroup])

 

How do i modify issue.setCustomFieldValue function such that i will be able to set more than one group?

 

Thanks 

Swathi

1 answer

1 accepted

2 votes
Joshua Yamdogo Community Champion Nov 14, 2017

Hi Swathi,

Have you tried adding your groups to a list and then setting the field using that list?

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

def TeamDatagroup = groupManager.getGroup("TeamData Approvers") //jira group
def BOgroup = groupManager.getGroup("Business Owners") //jira group
def groupList = [TeamDatagroup, BOgroup]
issue.setCustomFieldValue(multiGroupCf, groupList)
Joshua Yamdogo Community Champion Nov 16, 2017

Hi @Swathi Komirelli

Glad to hear it worked. Please accept my answer as the accepted answer so others with the same problem can find the solution easier.

Thanks for using ScriptRunner!

Josh

Hey @Joshua Yamdogo [Adaptavist], the above code works like a charm for post function but somehow it fails on custom listener. So I'm trying to update the group picker field when an issue is assigned to someone based on their group subscription. 

Thanks in advance.

 

Madhu

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,317 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot