It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Unable to change issue status using groovy in Jira Service Desk

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

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

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.

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()

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()}")
}

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

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you