Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to transiton from current status to a given status?

liansheng zhang November 4, 2018

I have an principle to implement. If the issue is cancelled, all its subtasks shall be cancelled automatically without screen checking only if the subtask has an action from current status to the "cancelled" status.

I have following codes but don't know how to get ACTION_ID which can transition the subtask from current status to a given status ( here, the given status is "cancelled" ). any one could kindly help?

 


def subTasks = issue.getSubTaskObjects()
subTasks.each {
def
validationResult = issueService.validateTransition(user, it.id, ACTION_ID, issueInputParameters)
if (validationResult.isValid()) {
def issueResult = issueService.transition(user, validationResult)
}
}

 

1 answer

1 accepted

0 votes
Answer accepted
Gezim Shehu [Communardo]
Community Champion
November 5, 2018

The method I use to get the action id is

 

import com.opensymphony.workflow.loader.ActionDescriptor
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl
import com.atlassian.jira.workflow.IssueWorkflowManager
...

WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);
IssueWorkflowManager issueWflwMan = ComponentManager.getComponentInstanceOfType(IssueWorkflowManager.class);

....

int actionID
def actionName = "Cancelled" //transition name

Collection<ActionDescriptor> coll = issueWflwMan.getAvailableActions(subtaskIssue, user);
        for(ActionDescriptor ad : coll) {
            if(ad.getName().equals(actionName)) {
                actionID = ad.getId();
            }
        }
liansheng zhang November 6, 2018

great! thank you very much!

Gezim Shehu [Communardo]
Community Champion
November 6, 2018

Glad to help

Suggest an answer

Log in or Sign up to answer