Using the JIRA Server API, given a MutabaleIssue, how do I get a list of allowable transitions with names and IDs?
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
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.