Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to resolve issue programmatically?

ych July 25, 2012

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Jobin Kuruvilla [Adaptavist]
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.
July 25, 2012

Use IssueService. First execute validateTransition and then transition methods.

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

ych July 25, 2012

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

Jobin Kuruvilla [Adaptavist]
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.
July 25, 2012

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
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 25, 2012

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...

ych July 25, 2012

Can you provide a code snippet, please?

TAGS
AUG Leaders

Atlassian Community Events