Subtask created in postfunction not marked as subtask and parent = null

I have a system-wide java listener that records information about issues as they are created.  If I'm on a standard issue and do "More>Create Sub-task" the listener sees the create event and records the new subtask and doing things like subtask.getParentObject() or subtask.isSubtask() work as expected.

 

However, if the subtask is created using the "Create sub task" post function from script runner, my listener responds to the create event, but does not see the newly created issue as a subtask.  getParentObject() returns null and isSubtask() returns false.  I've tried to re-get the issue from the issueManager but that did not work.

I imagine this is related to: https://jamieechlin.atlassian.net/browse/GRV-346

Is there any way to get information about the parent when the subtask is being created by the script runner post function?

1 answer

I found the following workaround so that I do not need to make any changes to the listener. In the additional actions field on the Create Sub-Task post-function, I simply set the parent ID of the newly created issue like so:

long id = transientVars["originalissueobject"].getId()
issue.setParentId(id)

When the listener runs it now sees a parent when running getParentObject() or isSubtask(). I'm guessing the parent ID or parent object gets overwritten a split second later by the scriptrunner postfunction, but this was enough to get around the issue I was encountering.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

183 views 0 4
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