Hi,
I want to transition issue when linked issue (epic) is being transition from "Open" to "In Development", then the issue (Issue type: Change) relates to will move to "In Development"
I have used the code below but the issue is not transitioning:
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"]
// 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 == "In Testing") {
// Prepare our input for the transition
log.debug("Status == Display")
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with
{ setComment("Cancelled Vacation Request by HR") setSkipScreenCheck(true) }
// Validate transitioning the linked issue to "Signs Needed"
def validationResult = issueService.validateTransition(user, destIssue.id, 71, 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)")
}
}
Please screenshot of the different workflows and its ID:
Swarna
Hello @Swarna Radha
As i can see your link type "relates to" not "Relates"
replace
def linkType = ["Relates"]
to
def linkType = ["relates to"]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.