Transition a linked issue when parent/source issue performs a transition : Scriptrunner

Hi everyone,

After doing some research online, and editing/adding some script I came up with a postfunction that is suppose to transition a linked issue in another project.

 When the source issue gets moved from populate to review, I want the other issue(linked issue) within another project to get moved from Display to Not Display.  This post funtion lies in the source issue transition.  Can somone help me and let me know what I need to change to make the issues transition properly. My script and the logs are displayed below:


import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger
import org.apache.log4j.Level

def log = Logger.getLogger("com.acme.CreateSubtask")

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( {
    log.debug("entered for loop")
    def destIssue = link.getDestinationObject()
    // Does the name of the link match "relates to" ?
    if (linkType.contains( {
        log.debug("relates to is the link type")
        def destStatusObject = destIssue.getStatus()
 // Is the status of the linked issue "Display" ?
        if ( == "Display") {
            // Prepare our input for the transition
            log.debug("Status == Display")
            def issueInputParameters = issueService.newIssueInputParameters()
            issueInputParameters.with {
                setComment("Cancelled Vacation Request by HR")
            // Validate transitioning the linked issue to "Signs Needed"
            def validationResult = issueService.validateTransition(user,, 61, 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: ${} ${destIssue.key} ${} (wrong status)")
    } else {
        log.debug("Skipping link: ${} ${destIssue.key} (wrong type)")


2017-07-10 14:01:48,811 DEBUG [acme.CreateSubtask]: commence for loop
2017-07-10 14:01:48,811 DEBUG [acme.CreateSubtask]: entered for loop
2017-07-10 14:01:48,812 DEBUG [acme.CreateSubtask]: relates to is the link type
2017-07-10 14:01:48,812 DEBUG [acme.CreateSubtask]: Status == Display
2017-07-10 14:01:48,851 WARN [contact.ContactSelectCF]:  ContactSelectCF getValueFromCustomFieldParams 
2017-07-10 14:01:48,851 WARN [contact.ContactSelectCF]:  ContactSelectCF getValueFromCustomFieldParams singleParam 11417
2017-07-10 14:01:48,851 WARN [contact.ContactSelectCF]:  ContactSelectCF getValueFromCustomFieldParams option 11417 : Not defined
2017-07-10 14:01:48,851 WARN [contact.ContactSelectCF]: ContactSelectCF validateFromParams crm org option null for OAG-39
2017-07-10 14:01:48,851 WARN [contact.ContactSelectCF]:  ContactSelectCF :: store put Not defined : 19342_customfield_11711


1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,723 views 17 21
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you