Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Transition issue when linked issued is being transitioned Edited

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

1 answer

Hello @Swarna Radha

As i can see your link type "relates to" not "Relates"

replace
def linkType = ["Relates"]
to
def linkType = ["relates to"]

Hi @Mark Markov,

I have changes to 'relates to' still it is not transitioning.

Thanks

Swarna

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

3,894 views 11 5
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you