Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

create sub-task for each user in multi user picker

Justin Risser December 4, 2013

how can i create a sub-task for each user in multi user picker?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Justin Risser December 19, 2013

Here is the script I hacked together. This script is fired on the create issue workflow step. It creates a sub-task of type 41 for each user in the Technical response required from custom field. This is a multi-user picker. It also pulls the Technical response due by date field and sets the sub-task due date field.

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.ComponentManager

cfTech = ComponentManager.getInstance().getCustomFieldManager().getCustomFieldObjectByName("Technical response required from")
cfDate = ComponentManager.getInstance().getCustomFieldManager().getCustomFieldObjectByName("Technical response due by")

Collection<User> users= (Collection) issue.getCustomFieldValue(cfTech); 

if(users != null)
{ 
for(i in 0..users.size()-1)
{ 
Object AssigneeValue = users.get(i).getName();

issueObject = componentManager.getIssueFactory().getIssue()
issueObject.setProject(issue.getProject())
issueObject.setIssueTypeId("41") 
issueObject.setParentId(issue.getId())

issueObject.setSummary(issue.getSummary())
issueObject.setSummary("Technical response required for quote")
issueObject.setDueDate(issue.getCustomFieldValue(cfDate))
issueObject.setAssigneeId(AssigneeValue)
issueObject.setReporter(issue.getReporter())

subTask = componentManager.getIssueManager().createIssue(componentManager.getJiraAuthenticationContext().getUser(), issueObject)
componentManager.getSubTaskManager().createSubTaskIssueLink(issue.getGenericValue(), subTask, componentManager.getJiraAuthenticationContext().getUser())
i++
}

}

Rathna May 15, 2017

Hi Justin,

After alot of research and searching I found your post and I would like to know how to implement an multi approval workflow using subtasks with one multiple user picker. Would it be possible for your to guide me in implementing this. Since when i tried to cut and paste it I have seen alot of errors. I am using JIRA 6.4.12 and Scriptrunner 4.1.3.24

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2013

Depends under what circumstances you are thinking about. If you want to do this as part of a workflow transition, then Create on Transition Plugin for JIRA has support for that. See How to create multiple issues - advanced example

Justin Risser December 9, 2013

I am looking to create the sub-task(s) on a workflow transition. The plugin looks like a great option but I will not be able to license it at this time. I am trying to piece together groovy scripts that I've found. I am also looking for groovy documentation related to custom fields and multi user pickers.

Rok Antolic August 18, 2015

Hello Bob, is it possible to create subtasks for each group from group multipicker? Best regards, Rok

TAGS
AUG Leaders

Atlassian Community Events