I'm hoping that someone can help me since my research has not yielded any results.
I have the following requirements:
The code that I have currently written will fulfill Requirement 1...
import com.atlassian.jira.component.ComponentAccessor
def issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def subTasks = issue.getSubTaskObjects()
subTasks.each {
if (it.statusObject.statusCategory != "Done") {
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
setResolutionId("10500") // resolution of "Assumed Complete"
setComment("Sub-task was Closed (with a resolution of 'Assumed Complete') as a result of the Parent Item being Closed.")
setSkipScreenCheck(true)
}
// validate and transition subtask
def validationResult = issueService.validateTransition(user, it.id, 41, issueInputParameters) // transitionId of "Closed" for the Sub-task Workflow
if (validationResult.isValid()) {
def issueResult = issueService.transition(user, validationResult)
if (!issueResult.isValid()) {
log.warn("Failed to transition subtask ${it.key}, errors: ${issueResult.errorCollection}")
}
} else {
log.warn("Could not transition subtask ${it.key}, errors: ${validationResult.errorCollection}")
}
}
}
And I have a bit of a stop-gap coded where we display a notification that Sub-tasks will be closed (these appear in the upper-right hand corner) but I'd really like to make them actionable rather than notified. Here's the code for that notification...
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.properties.APKeys
def baseUrl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)
def issueUrl = "$baseUrl/browse/$issue.key"
UserMessageUtil.success("All 'New' or 'In Progress' Sub-tasks will be moved to a 'Closed' status as a result of this transition." )
But I cannot figure out how to accomplish Requirements 2-4. Has anyone been able to do something like this? Would you mind sharing your tips/tricks/code?
We're currently running on Jira Server 8.9.0 and have JSU and ScriptRunner.
Thanks so much!
You don't need Scriptrunner to do the screen part (and it couldn't do it anyway). Plain Jira already does almost all of it off-the-shelf.
Create a workflow that has a "transition screen" on the close transition. You probably want to put the "resolution" field on it. For added text, use a Jira Toolkit "message field for edit" on the screen to put your message on the screen.
Thank you, Nic! I had the Toolkit installed already but didn't know about that customField type!
I got one set up, and I have it on my Resolve Issue Screen... but I'm not sure how to set the default value for it - right now, nothing is appearing there (not even the custom field name).
Thanks so much for the assistance with this one!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nevermind! Needed to set the context for it under Default Value! Thanks so much for your assistance! :)
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.