Obtaining available workflow actions programmatically
Often in our programs, we may come across the need to retrieve the current workflow actions, available on the issue. Let us have a look at how to do this using the JIRA API.
How to do it...
Follow these steps:
Retrieve the JIRA workflow object associated with the issue:
JiraWorkflow workFlow = componentManager.getWorkflowManager().getWorkflow(issue);
Here, issue is the current issue, which is an instance of
com.atlassian.jira.issue.Issue
class.Get the issue status and use it to retrieve the current workflow step linked to the issue:
GenericValue status = issue.getStatusObject().getGenericValue(); com.opensymphony.workflow.loader.StepDescriptor currentStep = workFlow.getLinkedStep(status);
Retrieve the set of available actions from the current step:
List<ActionDescriptor> actions = currentStep.getActions();
Here,
actions
is a list ofcom.opensymphony.workflow.loader.ActionDescriptor
.Iterate on the
ActionDescriptors
and get the details for...