Link subtask to parent issue automatically with scriptrunner?



Has anyone successfully created a subtask on the Create transition and subsequently linked it to its parent issue automatically in the same transition with a script?


I'd really appreciate if you'd share how this can be done





1 answer

Hello Connor.

I believe this can be done with the SR Create Subtask post function.

Since it is a sub task, it needs to have a parent, so if you were to add this post-function in te onCreate transaction, it would create the subtask that you are looking for.

This is the dialog that you need to fill, and it can be accessed in the add postfunction dialog in the workflow transaction editor.

Screen Shot 2017-07-26 at 10.13.43.pngIf you have more questions do not hessitate to ask.





Thank you for the reply! I'm already able to create subtasks through this exact dialog- my question is how I can configure this dialog so that upon creation the subtask will be 'linked' to the parent issue - do you know how I could configure that?

Thanks a lot


Isn't that done automatically? When I create a subtask it links the parent on its own

That's a good point - a sub-task is always part of its parent and displays as such. The fact it is a sub-task means there is a link to the parent.

Creating an issue link as well is redundant (although if you looked at the code, you'd see an invisible "system" issue link is already there)

I'm running into something similar. There is a brief moment in time after the sub-task is created when it technically isn't linked to the parent. I know this is happening because I have a script listener that burns down the remaining estimate of the parent when the sub-task is created (this keeps the overall remaining estimate accurate up the chain so we're not double-counting, as the Remaining Estimate of the parent includes the Remaining Estimates of its children when using Portfolio).

This functionality works properly at any level above sub-tasks (e.g. when I add an issue to an Epic) when issues are created, but I have to go back into the sub-task and update it in order for the functionality to work properly at this level. This is because the script listener is triggering off of Issue Created, Issue Updated, and Work Logged On Issue events.

Since the listener works properly when the issue is updated and works properly for other issue types, it seems like the subtask and parent aren't actually linked at the time that the Issue Created event fires. I've tried adding post functions that do nothing but sleep for a second or two, but this hasn't had an impact. I've also added a sleep to the beginning of the script listener.

So, does anyone have any idea of how to get the parent/sub-task link to happen more quickly? I've also tried creating a post function that transitions the subtask back to the same status and triggers an Issue Updated event, but this also didn't have an impact.

@Matt Parks any luck with this at all? I've just run into the same issue, and was about to try a solution similar to transitioning the subtask back to the same status...but you are saying that doesn't work. Have you tried doing that same thing in Script Listener? This is quite annoying.

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,943 views 19 22
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