Jira API to move to new Status is not working


I am working on Jira 8.5.3 and hosted locally in server. Currently i have an requirement is for a valid conditions , we can directly close the issue Status.

I am trying to achieve this using groovy post function . I have written the following code . But code is failing at validatetransition method at line 40 .
Hence i am not able to change the status to Closed.

Code snippet:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Level
import org.apache.log4j.Logger
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueInputParametersImpl

  • Created by kadhikar on 3/16/2021
  • Script upgraded with JIRA 8.5.3 API compatibility.

logger = log as Logger

Issue issue = issue
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField qaContactCF = customFieldManager.getCustomFieldObjectsByName(“QA Contact”).first()
ApplicationUser qaContact = (ApplicationUser) issue.getCustomFieldValue(qaContactCF)

logger.info(“qaContact>>” + qaContact)
logger.info(“Reporter>>” + issue.getReporter())
logger.info(“Assignee>>” + issue.getAssignee())

if (qaContact == issue.getReporter() && qaContact == issue.getAssignee()) {
logger.info(“Finally here”)
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.issueManager
IssueService issueService = ComponentAccessor.getIssueService()
def actionId = 7 // change this to the step that you want the issues to be transitioned to
def transitionValidationResult
def transitionResult
transitionValidationResult = issueService.validateTransition(currentUser, issue.id, actionId, new IssueInputParametersImpl())

if (transitionValidationResult.isValid()) {
transitionResult = issueService.transition(currentUser, transitionValidationResult)
if (transitionResult.isValid()) {
logger.debug(“Transitioned issue $issue through action $actionId”)
} else {
logger.debug(“Transition result is not valid”)
} else {
logger.debug(“The transitionValidation is not valid”)



In order to understand what the errors are - then hopefully figure out how to fix it -, have you checked the error collection from transitionValidationResult? That might help in pinpointing the errors encountered during the validation.

I have checked the error log and its saying actionID is Invalid .

Log >>>[The workflow operation with action id ‘7’ does not exist in the workflow.]

Can you please help me in understanding the Action ID here . For Close i can see the action id is 7 only.



In the above screenshot , Can we say Action id is 7 .


Hi JItendra, so far I can think of two things:

  1. Based on the error, it seems Closed is not supported in the current workflow (although the image you attached says otherwise). Can you check if the workflow for the specific issue you’re trying to transition supports the said action? I found this guide that might help you troubleshoot it.

  2. If the action does exist, you might want to check if currentUser has the necessary authorization to transition the issue.


Although i was able to transition issue using issue service . I can see the issue status is changed.
But in Issue view page i am not able to find the updated status .

Can anyone please help me .