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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

77 views 0 5
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