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

Script Runner - Optionally reopen a matching sub-task (Not Working)

Warren McInnes
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.
July 10, 2014

Hi, I have an issue where the Create Sub-task postfunction does not reopen the same same Sub-Task yet continues to re-produce new Sub-Tasks? Please advise?

Workflow:

Main Task -> Create -> In Progress -> Request Approval -> Implementation

Subtask -> Create -> Open -> Option 1: Approve -> Closed -> Reopen -> Open

Subtask -> Create -> Open -> Option 2: Decline -> Closed -> Reopen -> Open

On ST:Approve transition MT to Implementation

On ST:Decline transition MT to In Progress

On Request Approval Creates ST (Even when ST already exists? We want to Reopen the existing ST instead of always creating new)

Additional code on Request Approval -> Post Function -> Create ST:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.security.roles.ProjectRole
import com.atlassian.jira.security.roles.ProjectRoleActors
import com.atlassian.jira.security.roles.ProjectRoleManager

ComponentManager componentManager = ComponentManager.getInstance()
ProjectManager projectManager = componentManager.getProjectManager()
ProjectRoleManager projectRoleManager = ComponentManager.getComponentInstanceOfType(ProjectRoleManager.class) as ProjectRoleManager

def projectRole =projectRoleManager.getProjectRole("Approvers")
def actors =projectRoleManager.getProjectRoleActors(projectRole, issue.getProjectObject())
def approver =projectRoleManager.getProjectRoleActors(projectRole, issue.getProjectObject()).roleActors.find { true }

def issueEmergency =customFieldManager.getCustomFieldObject('customfield_12601')
def issueSummary =issue.getSummary()
def issuePriority =issue.getPriorityObject()

emergencyValue =issue.getCustomFieldValue(issueEmergency).getValue()

newSummary ="(" + emergencyValue + ") " + issueSummary + " - approval task."
oldSummary =issueSummary + " - approval task."

if(emergencyValue.equals("Emergency")){
issue.setPriorityId("1")
issue.setSummary(newSummary)
issue.setAssignee(approver.user)
}
else{
issue.setSummary(oldSummary)
issue.setAssignee(approver.user)
}

IS THERE ANYTHING PREVENTING REOPEN OF ST?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
JamieA
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.
July 10, 2014

Reopening a subtask looks for one with the specified summary, so won't work if you change the summary in the additional code.

Warren McInnes
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.
July 10, 2014

Is there a work around to this Jamie?

JamieA
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.
July 10, 2014

Other than to just write your own script, I can't think of one.

TAGS
AUG Leaders

Atlassian Community Events