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…
Let's perform the following steps to obtain available workflow actions programmatically:
Retrieve the JIRA workflow object associated with the issue:
JiraWorkflowworkFlow = ComponentAccessor.getWorkflowManager().getWorkflow(issue);
Here,
issue
is the current issue, which is an instance of thecom.atlassian.jira.issue.Issue
class.Get the issue status and use it to retrieve the current workflow step linked to the issue:
Status status = issue.getStatusObject(); 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...