Hello!
I need some help about scripted post function. I want to fire an Action (ex: Sent to Review) as a Post Function another transition (ex: Integrate) if a complicated condition goes true.
I have some questions:
1, Is it possible to fire an Action (transition) as a post function of another transition.
I am writing you the whole situation and my expectation. If anybody has idea how to figure out the solution please answer me.
I want to fire automatic transitions on my parent issue depending on sub-task's status, different sub-task types and different statuses. All automatic transition has different condition concern to sub-task's types and statuses and the parent issue is must be in specified status.
Here is what is made:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.util.UserManager
import java.util.logging.Logger;
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.IssueInputParameters
public void doTransition(String statusId, int transitionId) {
try{
Thread thread = Thread.start {
sleep(1000);
IssueService issueService = ComponentAccessor.getIssueService()
UserManager userManager = (UserManager) ComponentAccessor.getUserManager()
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
issueInputParameters.setStatusId(statusId);
IssueService.TransitionValidationResult transitionValidationResult = issueService.validateTransition(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issue.id, transitionId, issueInputParameters);
if (transitionValidationResult.isValid()){
IssueService.IssueResult transitionResult = issueService.transition(currentUser, transitionValidationResult);
if (!transitionResult.isValid()) {
transitionResult.errorCollection.errorMessages.each {log.error "Error Message: $it"}
transitionResult.errorCollection.errors.each {log.error "Error: $it"}
transitionResult.errorCollection.reasons.each {log.error "Reason: $it"}
}
} else {
transitionValidationResult.errorCollection.errorMessages.each {log.error "Error Message: $it"}
transitionValidationResult.errorCollection.errors.each {log.error "Error: $it"}
transitionValidationResult.errorCollection.reasons.each {log.error "Reason: $it"}
}
}
} catch (Exception e){
log.error(e.getMessage());
}
}
def subtasks = issue.getSubTaskObjects();
def cFieldValue = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_22200")) // status before trigger
def goToReproduction = false;
def goToProcessing = false;
def goToIntegrating = false;
def goToVerifying = false;
def goToConcluding = false;
for (int i=0; i < subtasks.size(); i++)
{
def nextIssue = subtasks[i];
if (cFieldValue == 'Categorizing')
{
if (nextIssue.getIssueTypeId() == "13602" && nextIssue.getStatus()?.name != 'New')
{
goToReproduction = true
break;
}
}
else if (cFieldValue == 'Reproduction')
{
if ((nextIssue.getIssueTypeId() == "13603" || nextIssue.getIssueTypeId() == "13701") && nextIssue.getStatus()?.name != 'New')
{
goToProcessing = true
break;
}
}
else if (cFieldValue == 'Processing')
{
if ((nextIssue.getIssueTypeId() == "13603" || nextIssue.getIssueTypeId() == "13701") && nextIssue.getStatus()?.name == 'Closed')
{
goToIntegrating = true
break;
}
}
else if (cFieldValue == 'Integrating')
{
if ((nextIssue.getIssueTypeId() == "13507" && nextIssue.getStatus()?.name != 'New'))
{
goToVerifying = true
break;
}
}
else
{
}
}
if (goToReproduction){
doTransition("3", 21);
}
if (goToProcessing)
{
doTransition("4", 31);
}
if (goToIntegrating)
{
doTransition("5", 41);
}
if (goToVerifying)
{
doTransition("6", 51);
}
if (goToConcluding)
{
doTransition("7", 61);
}Does anybody have better solution then mine, without hack?