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 based on linked issues status

My requirement:

I have an story in Project P1 and two linked task L1 and L2 (blocks story) in different project P2

I want my story to change its state automatically based on tis linked issue state For e.g. Change state of epic to Done only when all the linked issues are set to In Done


I tried using the post function for Project P2 for transition state: In progress  (21) and Done (31)

Post function created was  "Transition 21 will be triggered on all issues linked to the current issue through the blocks link type." without any conditon

Post function created was  "Transition 31 will be triggered on all issues linked to the current issue through the blocks link type." without any conditon


But the outcome is not what I expect . Status of epic changes if I alter one of the linked issues and keeps on changing each time I update any of the linked issue


For e.g. i change the status of L1 to Done. In that case epic also gets set to Done (even though L1 is in Inprogress state)


Unfortunately I am not able to find solution to it after going through online articles and exploring the options within JIRA Agile


Can someone help me with it?


If adding condition to post function will solve this, can someone share groovy script to change the status for the example above then it would be great

3 answers

Any inputs on this?


@Nic Brough [Adaptavist] , @Jobin Kuruvilla, Jamie Echlin : Was going through the leaderboard and came across your name. Can you guys help me with this?

Tried out 

Using the script post function option in project P2 and selecting the Custom script post-function option, I included the below script to it (I have no hands on groovy script and came with this script after referring to multiple online article and modifying it) and moved this function after the fire event


import org.apache.log4j.Category

import com.atlassian.jira.ComponentManager

import com.atlassian.jira.issue.Issue

import com.atlassian.jira.project.Project


import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.bc.issue.IssueService

import com.atlassian.jira.bc.issue.IssueService.TransitionValidationResult

import com.atlassian.crowd.embedded.api.User


def Category log = Category.getInstance("com.onresolve.jira.groovy.TransitionToDone")


User currentUserObj = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()


issueManager = ComponentAccessor.getIssueManager()

linkMgr = ComponentAccessor.getIssueLinkManager()

projectMgr = ComponentAccessor.getProjectManager()

issueIndexMgr = ComponentAccessor.getIssueIndexManager()

log.debug ("Current issue ID: " +

log.debug ("Looking for Links...")


//Iterate through the  issue's links

for (IssueLink link in linkMgr.getOutwardLinks( {

    def issueLinkTypeName =

    def linkedIssue = link.getDestinationObject()

    def linkProjectName = linkedIssue.getProjectObject().getName()

    def linkedIssueKey = linkedIssue.getKey()

    def linkedIssueID = linkedIssue.getId()

    def linkedIssueStatus = linkedIssue.getStatusObject().getName()


    //look for a link that blocks 

    if (issueLinkTypeName == "Blocks") {

        log.debug ("issue "+ issue.getKey() + " blocks ")

        def allClosed = true


        //go to tech support issue and see if it has other open blockers

        for (IssueLink parentIssueLink in linkMgr.getInwardLinks(linkedIssueID)) {

            def parentIssue = parentIssueLink.getSourceObject()

            def parentIssueKey = parentIssue.getKey()

            def parentIssueID = parentIssue.getId()

            def parentIssueLinkType =

            def parentIssueStatusName = parentIssue.getStatusObject().name

            log.debug ("parentIssueLinkType = " + parentIssueLinkType)

            if (issue.getKey() != parentIssueKey  && parentIssueLinkType == "Blocks") {

                if (parentIssueStatusName == "Closed") {

                    log.debug ("Issue " + parentIssueKey + " is closed")

                } else {

                    log.debug ("Issue " + parentIssueKey + " is still open")

                    allClosed = false




        log.debug ("All issues closed? " + allClosed)


        //if no other blockers remain open, try to transition the issue

        if (allClosed) {


            log.debug ("Transition issue " + linkedIssueKey)

            issueService = ComponentAccessor.getIssueService()

            issueInputParameters = issueService.newIssueInputParameters()

            TransitionValidationResult validationResult = issueService.validateTransition(currentUserObj, linkedIssue.getId(), actionID, issueInputParameters)

            if (validationResult.isValid()) {

            // Transition linked issue to status = "Done"

                issueService.transition(currentUserObj, validationResult)

                log.debug ("Transitioned")

                // Re-index issue


                log.debug ("Reindexed")

            } else {

                Collection<String> errors = validationResult.getErrorCollection().getErrorMessages()

                for (errmsg in errors) {

                    log.debug ("[ERROR] - Error message:" + errmsg)






But this script don't seem to work out. Could you please correct me on it?

What log output do you have?

I have no clue where to check the log output. I am checking it on UI after changing the transition for all the linked issues to done

You need to find out before you have such an involved question.

I was under the impression that groovy script for the requirement would already be handy as this seems to be a common case If you think I need to get into the details of it, then surely will do. Thanks

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'MGoodar2(mgoodar2)' with class 'com.atlassian.jira.user.DelegatingApplicationUser' to class 'com.atlassian.crowd.embedded.api.User'

hello @qatest Did you figure out any answer? More or less I am looking for same functionality as this and I was wondering if you made any progress and help me..Thank you

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Software

Early Access: If you use Jenkins and Jira Software Cloud, you need to read this!

The Jira Software Cloud Team has been busy working on a simple, secure, and reliable way to integrate your build and deployment information from Jenkins with Jira Software Cloud. This means you don’t...

704 views 0 11
Read article

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