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
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

455 views 8 27
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