Hi,
How can I automatically creates few sub-tasks with fix summary I define for each subtasks on JIRA issue Creation (Story / task any normal issue type) & also put quick check like if Template (Custom field - type select list single choice) = Template 1 then create sub-task else ignore.
Based on that I will put another post function with same script & check if Template = Template 2 then create sub task else ignore it.
I want to use groovy script for this as script runner is providing option to put inline groovy or file groovy.
Capture 2016-03-01 at 15.44.10.png
Currently I am able to create sub tasks based on Script runner post function "Create Sub task" but if I need to create 15 sub tasks then I need to add separate 15 PFs in workflow & if need to modify summary then again update 15 Post functions !!
Capture 2016-03-01 at 15.38.21.pngCapture 2016-03-01 at 15.39.55.png
So please suggest if you are using groovy for auto creating subtasks. I already searched old answers but as I am new to groovy I am not getting where to put name/id of my project & where to put name of my subtasks. also I need small check of custom field as I mentioned above. So please suggest on this.
Thanks,
Hardik
I have tested the script and it works.
How can I modify it to replace the current list for summariesList
by the selected values from a field type Checkboxes
Thank you in advance for your help
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.customfields.option.Option def customFieldManager = ComponentAccessor.customFieldManager def cf = customFieldManager.getCustomFieldObjectByName("My checkboxes field") def summariesList = (issue.getCustomFieldValue(cf) as Collection<Option>)*.value
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
This is awesome do you know if their is a way to have multiple field for one subtask.
For exemple.
I try to have multiple column to select from
C1 (Ressource) C2(Summary) C3(Estimate effort) C4 (Start Date) c5 (End Date)
The first one has multiple
C2 is a text box
C3 Is a number
C4-C5 are date picker
I want to be able to add mutliple line to create multiple subtaks....
Is this can be adapt to have this kind of setup
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You want something like the following. Just check custom field values to see whether to create the sub-tasks or not:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.MutableIssue def parentIssue = event.issue if (parentIssue.getIssueType().getName() != 'New Employee') return def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() def summariesList = ["summary1", "summary2", "summary3", "summary4", "summary5", "summary6"] def issueFactory = ComponentAccessor.getIssueFactory() def subTaskManager = ComponentAccessor.getSubTaskManager() def constantManager = ComponentAccessor.getConstantsManager() def issueManager = ComponentAccessor.getIssueManager() summariesList.each { subTaskSummary -> MutableIssue newSubTask = issueFactory.getIssue() newSubTask.setSummary(subTaskSummary) newSubTask.setParentObject(parentIssue) newSubTask.setPriorityId(constantManager.getPriorities().find { it.getName() == "High" }.id) newSubTask.setProjectObject(parentIssue.getProjectObject()) newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{ it.getName() == "Sub-task" }.id) // Add any other fields you want for the newly created sub task log.debug("New issue ${newSubTask}") Map<String,Object> newIssueParams = ["issue" : newSubTask] as Map<String,Object> issueManager.createIssueObject(user, newIssueParams) subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user) log.info "Issue with summary ${newSubTask.summary} created" }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
I'm looking to do something similar, but instead of creating a set number of subtasks I want to create X based on the value of a numeric field on the parent issue. The subtasks would inherit values from the parent for most fields. What would the script look like for something like that?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.