I want to update the status from all issues in a proejct with this code, but it doesnt work:
But if i just update the description this works fine, but not for the status.
I tried different ids but nothing helped.
Collection<Long> issueIds = getIssuesIdsFromProject(clonedProject);
IssueService issueService= ComponentAccessor.getIssueService();
for(Long id:issueIds){
MutableIssue issue=getIssueFromId(id);
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
issueInputParameters.setStatusId("1");
UpdateValidationResult updateValResult = issueService.validateUpdate(currentUser, issue.getId(), issueInputParameters);
if(updateValResult.isValid()){
IssueResult updateResult = issueService.update(currentUser, updateValResult);
}else{
throw new RuntimeException("Status for Issue" + issue.getKey() + "not valid");
}
}
Is this even possible with the setStatusId Method or do i need to traverse all transtion actions which would be much more effort to implement?
Hello,
You cant not use setStatusId to transition issue. Your code would look like that:
def issueInputParameters = issueService.newIssueInputParameters() issueInputParameters.with { setComment("Comment") setSkipScreenCheck(true) } def validationResult = issueService.validateTransition(user, issue.id, 12, issueInputParameters) if (validationResult.isValid()) { def issueResult = issueService.transition(user, validationResult) if (! issueResult.isValid()) { log.warn("Failed to transition task ${destIssue.key}, errors: ${issueResult.errorCollection}") } } else { log.error("Could not transition") }
If your desired status does not have a direct transition to the required status you need to go through all transitions to reach it.
Actually you can create transitions from all statuses to required status . Choose in the workflow settings From status: Any status To status: <your status>.In this case you can always go from any status to the required status. Also add Hide transition from user condition to hide these transitions Jira users.
Ok thank you for your answer.
Is this programmatically possible with java to create new transitions at runtime?
The problem is that is should work for any workflows. So i dont know which actions are available to reach the state.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Or is there a way to get all outgoing transitions with the corresponding actions from the current status of the issue ?
I think this would be the easiest approach to solve my problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, you can get all outgoing transitions. The code would be like this
IssueWorkflowManager issueWorkflowManager = ComponentAccessor
.getComponentOfType(IssueWorkflowManager.class);
def actions = issueWorkflowManager.getAvailableActions(issue, user)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.