Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi All,
Just stuck on searching a solution for following complex functionality:
When parent issue transitioned to status Resolved and it has Sub-tasks opened then all opened Sub-tasks should be transitioned to status Resolved as well and Sub-tasks should get resolution value that user chose on resolution screen while transitioning parent issue and if user adds a comment on resolution screen that comment should be added to Sub-tasks.
I've been searching google few days for this but could not find a solution how to catch comment that user enter on resolution screen on parent issue, and also no success to get resolution value that user choose on resolution screen on parent issue to paste it to Sub-tasks.
The code I could write with scriptrunner documentation just can transition sub-tasks when parent issue is transitioned and change sub-tasks resolution to pre-defined value and adds pre-defined comment. But it's not an option for us. Because if user does not enter any comment on transition this code gets last comment from the issue anyway..
Attaching my code below:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.config.SubTaskManager
Issue issue = issue
def constantManager = ComponentAccessor.getConstantsManager()
def issueService = ComponentAccessor.getIssueService()
def cwdUser = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
SubTaskManager subTaskManager = ComponentAccessor.getSubTaskManager()
Collection subTasks = issue.getSubTaskObjects()
if (subTaskManager.subTasksEnabled && !subTasks.empty) {
subTasks.each { Issue it ->
def commentManager = com.atlassian.jira.component.ComponentAccessor.getCommentManager()
def commentCatch = commentManager.getLastComment(issue)
def text = commentCatch.body
String comment = "*Resolved* Last comment from the parent issue: $text";
def issueInputParameters = new IssueInputParametersImpl()
def doneResolutionId = constantManager.getResolutions().find {it.name == "Done"}?.id
def doneStatusId = constantManager.getStatuses().find {it.name == "Done"}?.id
issueInputParameters.setResolutionId(doneResolutionId).setStatusId(doneStatusId).setComment(comment)
def transitionValidationResult = issueService.validateTransition(cwdUser, it.id, 5, issueInputParameters)
log.debug("Validation result : ${transitionValidationResult.errorCollection}")
if (transitionValidationResult.isValid()) {
log.debug("Transition for sub task ${it.key} is valid")
issueService.transition(cwdUser, transitionValidationResult)
}
}
}
Thank you in advance for help or advise!
Jira Software 8.1.1 (Server)
Scriptrunner Version 5.5.6.1-jira8
Те, если коммента нет, дочек не нужно резолвить, а если есть нужно?
Нужно резолвить в любом случае. А если еще и комментарий написали во время перехода, тогда этот комментарий нужно к каждому саб-таску прикрепить.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register Now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.