Hello,
I am asked to update the script that Thanos Batagiannis [Adaptavist] has provided. Please see it below.
We would like to have subtask 1 and 2 with descriptions as it stated below ( samples) every time we receive new employee ticket. Is it possible to have subtask 1 and 2 with the descriptions ?
Your help is greatly appreciated.
Description for Subtask 1:
To Do List 1
- Active Application Add-ins Lists the extensions that are registered and currently running in your Office program.
- Inactive Application Add-ins Lists the add-ins that are present on your computer but are not currently loaded. For example, smart tags or XML Schemas are active only when the document that references them is open. Another example is the COM add-ins that are listed in the COM Add-ins dialog box. If the check box for a COM add-in is selected, the add-in is active. If the check box for a COM add-in is cleared, the add-in is inactive. To learn how to open the COM Add-in dialog box, see the section called Turn off or manage the installed add-ins.
- Document Related Add-ins Lists template files that are referenced by currently open documents.
- Disabled Application Add-ins Lists add-ins that were automatically disabled because they are causing Office programs to crash.
Description for Subtask 2:
To Do list 2:
- Active Application Add-ins Lists the extensions that are registered and currently running in your Office program.
- Inactive Application Add-ins Lists the add-ins that are present on your computer but are not currently loaded. For example, smart tags or XML Schemas are active only when the document that references them is open. Another example is the COM add-ins that are listed in the COM Add-ins dialog box. If the check box for a COM add-in is selected, the add-in is active. If the check box for a COM add-in is cleared, the add-in is inactive. To learn how to open the COM Add-in dialog box, see the section called Turn off or manage the installed add-ins.
- Document Related Add-ins Lists template files that are referenced by currently open documents.
- Disabled Application Add-ins Lists add-ins that were automatically disabled because they are causing Office programs to crash.
Here is the script below;
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
def parentIssue = event.issue
if (parentIssue.getIssueType().getName() != 'New Employee')
return
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def summariesList = ["Subtask 1",
"Subtask 2",
"Notify the Risk Team of New Employee",
"Subtask 3"]
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def constantManager = ComponentAccessor.getConstantsManager()
def issueManager = ComponentAccessor.getIssueManager()
def userManager = ComponentAccessor.getUserManager()
def watcherManager = ComponentAccessor.getWatcherManager()
Issue Notify_the_Risk_Team_of_New_Hire
//here we fill an array with all required watchers
List<ApplicationUser> newWatchers = new ArrayList<>()
newWatchers.add(userManager.getUserByName("susie"))
newWatchers.add(userManager.getUserByName("elif"))
newWatchers.add(userManager.getUserByName("luiz"))
summariesList.each { subTaskSummary ->
MutableIssue newSubTask = issueFactory.getIssue()
newSubTask.setSummary(subTaskSummary)
newSubTask.setParentObject(parentIssue)
newSubTask.setPriorityId(constantManager.getPriorities().find {
it.getName() == "Major"
}?.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
//if the summary is Notify¬_the_Risk_Team_of_New_Hire then
if (subTaskSummary.equals("Notify the Risk Team of New Hire")) {
def assignee = userManager.getUserByName("susie")
newSubTask.setAssignee(assignee)
Map<String,Object> newIssueParams = ["issue" : newSubTask] as Map<String,Object>
Notify_the_Risk_Team_of_New_Hire = issueManager.createIssueObject(user, newIssueParams) as Issue
subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user)
} else {
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"
}
if (Notify_the_Risk_Team_of_New_Hire) {
newWatchers.each {
watcherManager.startWatching(it, Notify_the_Risk_Team_of_New_Hire)
}
}