It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Add req participants on workflow transition based on groups

Davor Fisher Community Leader Nov 20, 2017

We are looking to add participants based on a workflow transition but rather than adding it via users we would like to be able to do it from the group.

 

I found this article that gives us the option to do it by users defined in the script. Would it be possible to define it by group rather than individual users so the script would not have to be updated when users are added/leave.

https://confluence.atlassian.com/jirakb/how-to-automatically-add-request-participants-when-creating-an-issue-777026955.html

 

2 answers

5 votes
Johnson Wang Nov 30, 2017

Hi @Davor Fisher,

One other option for you to consider is the Power Scripts add-on. With much fewer lines of code, you can quickly and easily add request participants on workflow transition based on groups.

We've put together a quick 5 min video showing you how to set this all up. We've also included the sample script we used so you can just copy and paste it to try it yourself.

Hope this helps!

Johnson

0 votes
Joshua Yamdogo Community Leader Nov 20, 2017

Hi Davor,

This should be possible. Essentially, you'd just need to get the users out of the group and then set the field with those users. I answered a similar question here: https://community.atlassian.com/t5/Jira-Service-Desk-questions/Using-Scriptrunner-to-define-approvers-based-on-multiple-groups/qaq-p/664935#M8176

Use the groupManager to get users from a given group:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

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

def group = groupManager.getGroup("Managers")
def usersInGroup = groupManager.getUsersInGroup(group)
def fieldToSet = customFieldManager.getCustomFieldObjectByName("Request Participants")
fieldToSet.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(fieldToSet), usersInGroup), new DefaultIssueChangeHolder())
Greg Mora Jan 19, 2018

If I am trying to make this triggered by an "update issue" event, what needs to change?

 

I am getting this error when trying to implement this. 

at com.atlassian.jira.issue.Issue$getCustomFieldValue$3.call(Unknown Source)

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Jira Software

How to prevent the propagation of unused project schemes, workflows & screens in Jira software

Atlassian ranks project attributes as the third most important factor impacting performance in the category of data. It’s not surprising, since project attributes are precisely the rules used to ma...

1,568 views 1 19
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you