Close Issue update does not work

without problems:

MutableIssue mutableParentIssue = issueManager.getIssueObject(id);
mutableParentIssue.setEstimate(120);
issueManager.updateIssue(mutableParentIssue.getAssignee(), mutableParentIssue, EventDispatchOption.ISSUE_UPDATED, false)

doesn't work:

MutableIssue mutableParentIssue = issueManager.getIssueObject(id);
mutableParentIssue.setStatusId("6"); // closed
issueManager.updateIssue(mutableParentIssue.getAssignee(), mutableParentIssue, EventDispatchOption.ISSUE_UPDATED, false)

why?

the self problem with mutableParentIssue.setStatusObject(..

1 answer

You cannot simply set the status. Use IssueService to transition the issue until it reaches the CLOSE status (you may need to perform multiple transitions if you do not have direct transitions defined).

Something like that:

IssueService issueService = ComponentManager.getInstance().getIssueService();
TransitionValidationResult resultValidation = issueService.validateTransition(user, issueId, actionId, inputParameters);
if (resultValidation.isValid()) {
         result = issueService.transition(user, resultValidation);
         errors = result.getErrorCollection();
}

Note: I wrote it just by looking at docs; I think somebody posted a more complete code here ...

yes please more complete anyone. I dont understand to configure the issueInputParameters by IssueInputParametersImpl. Why i must self define the action parameter map.... . resultValidation.isValid() is alway false :(

i know this api.. but i run in dead ends.

MutableIssue mutableParentIssue = issueManager.getIssueObject(parentID);

IssueService issueService = ComponentAccessor.getIssueService();

IssueInputParameters issueInputParameter = issueService.newIssueInputParameters();

issueInputParameter.setSummary(mutableParentIssue.getSummary())

issueInputParameter.setDescription(mutableParentIssue.getDescription())

issueInputParameter.setAssigneeId(mutableParentIssue.getAssigneeId())

issueInputParameter.setReporterId(mutableParentIssue.getReporterId())

issueInputParameter.setProjectId(mutableParentIssue.getProjectObject().getId())

issueInputParameter.setIssueTypeId(mutableParentIssue.getIssueTypeObject().getId())

TransitionValidationResult resultValidation = issueService.validateTransition(mutableParentIssue.getAssignee(), mutableParentIssue.getId(), actionId, issueInputParameter);

only false, I tried all actionId

thanks a lot that was a very helpful pokes :P

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

172 views 0 4
Read article

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