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) newSubtask.assignToUser(currUser) newSubtask.linkToParentIssue }
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.
Notes:
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.
Hi Steve! For this kind of questions, I'd recommend you to go to community.developer.atlassian.com, so our developer community can help you out :)
Cheers,
Ana
Hi Steve! For developer questions, it's better that you post them at community.developer.atlassian.com, that's where our developer community hangs out :)
Cheers,
Ana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.