Forums

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

How to get allowable transitions?

Paul Tiseo
Contributor
June 7, 2018

Using the JIRA Server API, given a MutabaleIssue, how do I get a list of allowable transitions with names and IDs?

1 answer

2 votes
Mark Markov
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.
June 7, 2018

Hello, @Paul Tiseo 

For this you shoud use workflowmanager.

Get issue workflow and workflow object contains methods to get info you need.

Here is example to do in Script Console

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.workflow.JiraWorkflow
import com.opensymphony.workflow.loader.ActionDescriptor
import com.opensymphony.workflow.loader.StepDescriptor

def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("AP-1")
def workflowManager = ComponentAccessor.getWorkflowManager()
JiraWorkflow workflow = workflowManager.getWorkflow(issue);
def allactions = workflow.getAllActions()
log.error("All actions ID and names" + allactions.collect {it.name+ ' '+ it.id})


getAllActions return collection of Action descriptor objects that represents transitions.
for more info you can see atlassian api. There are many more methods.
https://docs.atlassian.com/software/jira/docs/api/7.2.0/com/atlassian/jira/workflow/JiraWorkflow.html

Paul Tiseo
Contributor
June 7, 2018

Sorry, should have been more specific: given an issue, how do I get all the transitions an issue can go through from the current state/status?

Mark Markov
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.
June 7, 2018

Oh, check this code then:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.workflow.JiraWorkflow
import com.opensymphony.workflow.loader.ActionDescriptor
import com.opensymphony.workflow.loader.StepDescriptor

def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("AP-1")
def workflowManager = ComponentAccessor.getWorkflowManager()
JiraWorkflow workflow = workflowManager.getWorkflow(issue);
def allactions = workflow.getAllActions()
log.error("All actions ID and names" + allactions.collect {it.name+ ' '+ it.id})

StepDescriptor stepDescritpor = workflow.getLinkedStep(issue.getStatus())
List<ActionDescriptor> outActions = stepDescritpor.getActions()
log.error("All outgoung actions ID and names" + outActions.collect {it.name+ ' '+ it.id})

getLinkedStep() returns StepDescriptor that represent status state for current workflow. And it has method to retrieve outgoing Actions.

Suggest an answer

Log in or Sign up to answer