Script to perform something on each user of a group (size of group is a variable) Edited

I am trying to procure a script that ultimately creates one subtask for each user in a custom-field-specified group. 

There are six possible groups, each of which is going to have a different number of users.

The group will be designated by a Single Group Picker custom field called "Needs approval from". For example, a customer could select "web-server-group", which contains three users. Or, they could select "network-device-group", which contains five users.

What I need

Code that will I need take the value of "Needs approval from", and for each user in the group, create one subtask, link it to parent issue, and (ideally) assign it to that user. The assignment is not crucial but would be very helpful.

Here is some VERY ROUGH pseudocode — I know that many of these steps require accessors, managers, etc. But this is the general outline of what I'm trying to accomplish.

group = ("Needs approval from").value
groupSize = group.size

int i 
for (i = 0; i < groupSize; i++) {
      currUser = group[i]
      newSubtask = createSubtask(currUser)

Any and all help turning the above pseudocode into functioning Groovy would be greatly appreciated.

I am very new to Groovy, but I do know how to use the ComponentAccessor and GroupManager. I'm having trouble understanding how to get the actual group in the form of a collection that allows me to iterate through it and perform actions on the elements (users) within it.


I have tried the Create Issue post function from the Create on Transition plugin from Bob Swift, which almost gets me there — it allows me to create multiple subtasks on one transition, but it doesn't accept a user group as the designator of how many subtasks to create. 

I am extremely averse to hardcoding groups, hardcoding custom fields with groups and their users, and using multiple workflows, because the idea is to replicate this process in other projects. If group membership changes, or if we implement this in several other projects, it will certainly cause more headaches than it prevents.

2 answers

0 votes

Hi Steve! For developer questions, it's better that you post them at, that's where our developer community hangs out :)



0 votes

Hi Steve! For this kind of questions, I'd recommend you to go to, so our developer community can help you out :)



Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,952 views 19 22
Read article

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