Hi ,
I'm working on a postfunction using scriptrunner. I want to perform transition of all issue under epic of link type- issues in epic to in progress when epic transition from open to start working.Can you suggest.
Thanks,
Sri
I use the following code but didn't work .No action is performed
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)
def issueService = ComponentAccessor.getIssueService()
//def linkType = ["relates to"]
// 6.x validateTransition wants a User, so we have to use getDirectoryUser()
// 7.x validateTransition wants an ApplicationUser, so remove the .getDirectoryUser() after we upgrade
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def linkMgr = ComponentAccessor.getIssueLinkManager()
// Look through the outward links
log.debug("commence for loop")
for (IssueLink link in linkMgr.getOutwardLinks(issue.id)) {
log.debug("entered for loop")
def destIssue = link.getDestinationObject()
// Does the name of the link match "relates to" ?
// if (linkType.contains(link.issueLinkType.name)) {
log.debug("relates to is the link type")
def destStatusObject = destIssue.getStatus()
// Is the status of the linked issue "Display" ?
if (destStatusObject.name !="" ) {
// Prepare our input for the transition
// log.debug("Status ==Open")
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
}
// Validate transitioning the linked issue to "Signs Needed"
def validationResult = issueService.validateTransition(user, destIssue.id,211, issueInputParameters)
if (validationResult.isValid()) {
log.debug("Validation Result is valid")
// Perform the transition
def issueResult = issueService.transition(user, validationResult)
if (! issueResult.isValid()) {
log.debug("Failed to transition task ${destIssue.key}, errors: ${issueResult.errorCollection}")
}
} else {
log.debug("Could not transition task ${destIssue.key}, errors: ${validationResult.errorCollection}")
}
} else {
log.debug("Skipping link: ${link.issueLinkType.name} ${destIssue.key} ${destStatusObject.name} (wrong status)")
}
}// else {
//log.debug("Skipping link: ${link.issueLinkType.name} ${destIssue.key} (wrong type)")
// }
//}
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.