Unable to change issue status using groovy in Jira Service Desk

Damian Wodzinski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2019

In my company, I was aksed if can I write a script, that will change status from "Resolved" to "Resolved by customer" if client resolve it.

So I added the needed status and created the script, the script is working correctly, but I think Jira Service Desk is preventing it from changing the status.

What's happening:
Client resolve the issue, so the status is changing to "Resolved". Script listener is picking it up and doing a transition to "Resolved by Customer" status. Then Jira discovers it and its changing status back to "Resolved".

In logs I have this:

WARN [request.CustomerRequestInternalManagerImpl]: The first customer request status found, does not appear to match the actual issues current customer request status. Attempt a re-sort operation before return results


The more odd thing is that, on the issue I see "Resolved" status, in portal in issue details I can see "Resolved" status, but when I go to list of issues, I can see that they have "Resolved by Customer" Status.

Any idea how to baypass it?

2 answers

1 accepted

0 votes
Answer accepted
Damian Wodzinski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 6, 2019

I got it working by using Built In script listener called "Fast track transition".

0 votes
Will C
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2019

Hi there,

 

Can you share your script with us? I have written scripts to change issue status before but you have to use a transition you can't do it without using a transition.

Damian Wodzinski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 4, 2019

here are the fragments that do transition, I tried two different approaches, but the result is the same:

def user_object = userManager.getUserByName("dwodzinski") //before I used logged in user, tried to check if my account with admin right do difference

def transitionOptions = new TransitionOptions.Builder()
.skipConditions()
.build()
if(issue.getStatusId() == "5"){
transitionValidationResult = issueService.validateTransition(user_object, issue.id, 1131, new IssueInputParametersImpl(), transitionOptions)
issueService.transition(user_object, transitionValidationResult)
log.error(issue.getStatus().name)
WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class );
workflowTransitionUtil.setIssue(issue);
workflowTransitionUtil.setAction(1121)
workflowTransitionUtil.setUserkey(user_object.getKey())
workflowTransitionUtil.progress()
Will C
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2019

This is the script I have used previously to transition is

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueInputParameters = issueService.newIssueInputParameters()
def wpAgreedStatus = 31
def WpIssue = issueManager.getIssueObject("1234")


IssueService.TransitionValidationResult validationResult = issueService.validateTransition(user, WpIssue.id, wpAgreedStatus, issueInputParameters)
if (validationResult.isValid()){
issueService.transition(user, validationResult)
} else {
log.debug("There is an error in the transition for ${WpIssue} errors: ${validationResult.errorCollection.toString()}")
}

Damian Wodzinski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2019

The transition is ok, my script change the status, but Jira change it back,

Kabelo Mokgoro October 13, 2020

Any progress on this?

* I think what our problems have in common is that we are trying to transition the issue while in a transition - a nested transition of sorts - which i don't think is supported. 

Suggest an answer

Log in or Sign up to answer