JIRA plugin development- Auto Transition utility method

If you are a JIRA plugin developer. you are in the right place. I am going to write down a utility method that will auto transition an issue from one status to another status. You may use this in Workflow Post functions, Restful service plugin extension, or any other type of Jira plugin/customization. Below, is the auto transition utility method.

	private boolean autoTransition(Issue issue,Integer actionId) {
			// Auto transaction to close
		IssueService issueService = ComponentAccessor.getIssueService();
		IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
		ApplicationUser adminUser= ComponentAccessor.getUserManager().getUserByName("administrator");
	    try {
	    List<GenericValue> workflowEntries = ComponentAccessor.getOfBizDelegator().findByAnd("OSWorkflowEntry", FieldMap.build("id", issue.getWorkflowId()));
	    for (GenericValue workflowEntry : workflowEntries) {
	        if (workflowEntry.getInteger("state") == null || "0".equals(workflowEntry.getInteger("state").toString())) {
	        	workflowEntry.set("state", new Integer(WorkflowEntry.ACTIVATED));
	    catch (GenericEntityException e) {
		if(actionId>0) {
			TransitionValidationResult tvr = issueService.validateTransition(adminUser, issue.getId(),actionId, issueInputParameters);
			if (tvr.isValid()) {
				issueService.transition(adminUser, tvr);
				return true;
			}else {
				return false;
		return false;

Above is a simple method that transition an issue. I will explain method here. First of all it accepts two parameter 1. Issue 2. Action Id.

So how to find the action id ? Follow below steps

  • You need to login as Jira administrator.
  • Go to settings
  • Click Issues
  • Click your work flow.
  • Edit it and find the transition button you want to trigger.
  • Please note the number at last in brackets with the transition text.
How to get transition id from workflow.

I have used Jira administrator user to transition the issue, but you may choose some other user as well. But that user should have permission to execute the transition. issueService.validateTransition the method will check all the permissions before performing the transition. At the end, if validates return true issueService.transition does the actual transition.

Above is a simple utility method that transition ans issue from one status to another. If you are Jira plugin developer it’s very handy for you. Enjoy 🙂

If you want to start JIRA plugin development from scratch, atlassian provides a good guide here

Please share this post:
Distinguished Engineer Java, PHP, Spring, Mysql
Posts created 11

Ask a Question

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

%d bloggers like this: