How to resolve issue programmatically?

When i set issue staus as resolved like that

issue.setStatusObject(resolvedStatus);
issue.setResolutionObject(resolution);

The status seems to be updated, but the resolve issue button at the issue page is still active. What should i do?

Thanks, in advance.

2 answers

1 accepted

3 votes
Answer accepted

Use IssueService. First execute validateTransition and then transition methods.

http://docs.atlassian.com/jira/latest/com/atlassian/jira/bc/issue/IssueService.html

Tell me please, how can i obtain a actionId for this method?

You can see the actionId in the workflow XML. If you want to get it programmatially, do something like this:

JiraWorkflow workFlow = componentManager.getWorkflowManager().
       getWorkflow(issue);
GenericValue status = issue.getStatusObject().getGenericValue();
       com.opensymphony.workflow.loader.StepDescriptor currentStep =
       workFlow.getLinkedStep(status);
List<ActionDescriptor> actions = currentStep.getActions();

And then iterate over actions and find the one to use.

Reference: p.121 JIRA Development Cookbook

1 vote

I think you're mixing up resolution, status and transitions.

Resolution is a flag saying how something was resolved. You can set that on-screen, via a workflow post function, or in code (exactly the method you have used). You have nothing wrong there.

However, the "resolve issue" button is a transition, which moves an issue through the workflow, from one status to another. It is NOT as simple as just setting a status, and you've broken your issue with your code. You might well be seeing the "correct" status on the issue, but you haven't moved it through the workflow, so it's now got the wrong status for the step it is on.

What you should do is:

  1. Remove or stop using the code you've written as it's breaking anything it touches.
  2. Run the integrity checker to repair any issues you have broken.
  3. Rewrite your code so that it moves things through the workflow, rather than just forcing a status in.

Edit - Jobin's post is the detail on step 3 of what I just scribbled...

Can you provide a code snippet, please?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted 7 hours ago in United States

Atlassian acquires AgileCraft

         Good Day, Bad bad traffic, not sure why!!!! 1/2 hour commute took me 2 hours today 🤯 What helped me is that I kept browsing LinkedIn until...

31 views 1 0
View post

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you