Script runner unable to create subtask with canned script

Trying to set up either a workflow post function or a groovy listener to create sub tasks automatically using the canned script with the script runner plugin. Either way I've set it up, I'm currently running into an error that says I cannot create a subtask on a ticket with a resolution. I'm at a bit of a loss at the moment since I've even tried this on a newly created issue and getting the same error. I would assume the NPE right before the error message is related. I'm using JIRA 6.0.5 and Script Runner 2.1.15.

2014-07-09 07:47:57,644 ajp-bio-10.105.9.114-8014-exec-7 ERROR 467x1924x1 yc0ktv 216.128.252.71 /secure/WorkflowUIDispatcher.jspa [groovy.canned.utils.ConditionUtils] javax.script.ScriptException: java.lang.NullPointerException
2014-07-09 07:47:57,645 ajp-bio-10.105.9.114-8014-exec-7 ERROR 467x1924x1 yc0ktv 216.128.252.71 /secure/WorkflowUIDispatcher.jspa [onresolve.jira.groovy.GroovyFunctionPlugin] Error executing post-function
com.atlassian.jira.exception.CreateException: Error occurred while creating issue through workflow: Cannot create a sub task on a ticket with a resolution.
        at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:498)
        at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:428)
        at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssueObject(DefaultIssueManager.java:513)
        at com.atlassian.jira.issue.IssueManager$createIssueObject.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
        at com.atlassian.jira.issue.IssueManager$createIssueObject.call(Unknown Source)
Caused by: [InvalidInputException: [Error map: [{}]] [Error list: [[Cannot create a sub task on a ticket with a resolution.]]]

1 answer

1 accepted

1 vote

Hmm, that does try to tell you what is wrong. I understand the logic behind it (if something is resolved, why on earth are you creating sub-tasks for it? It's done, you shouldn't be opening up more work on it!), but I'm not 100% sure if it's the script runner or your workflow. Either way, you need to reconsider why you're creating subtasks under resolved issues.

Error occurred while creating issue through workflow: Cannot create a sub task on a ticket with a resolution.


The thing is, I'm not trying to create a subtask on a resolved issue. I have tried this from a newly created issue. I've gone so far as to check the database to do a select from the jiraissue table to ensure that the resolution was not set there. I'm at a total loss for why this error message is appearing.

Restarted JIRA and got a different NPE before the big stack trace. The larger stack trace appears to be the same. I'm making guesses now, but maybe some sort of issue object is null and it's failing to get the resolution object on it. In turn, it's throwing the stack trace saying it can't create a subtask on a ticket with a resolution because something is in the conditional where it's checking that.

2014-07-09 09:14:07,113 ajp-bio-10.105.9.114-8014-exec-9 ERROR 554x438x2 10ctzre 216.128.252.71 /secure/WorkflowUIDispatcher.jspa [groovy.canned.utils.ConditionUtils] javax.script.ScriptException: java.lang.NullPointerException: Cannot get property 'resolutionObject' on null object

Ok, that is weird. You definitely don't have a resolution on the parent issue then. Wild guess - you're not setting one on the sub-task either?

That is a correct guess. I was hoping to start out with something basic and work my way up to what I want. Currently, the only thing I am setting through the script would be the subtask summary and the subtask type. There are no conditions on the function and there are no additional fields set.

There is a condition either on the function that creates the subtask, or in the workflow for the subtask (mostly likely on the create action). And that condition code is failing, it must be wrong.

Can you look for the condition?

Possibly you have a condition somewhere that is trying to check the resolution, but you're inadvertently using assignment rather than ==.

Looks like a simple scripted validator...? I removed the redundant frames from your stack trace to make it clearer.

There was a post function on the subtask create action that was trying to clear the resolution. I removed that and everything worked like I would expect.

Not sure why I ever put a post function there to do such a thing (why would the resolution be set when creating a ticket?). Guess it was just a matter of knowing where to look.

Thanks both Nic and Jamie for your help.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

145 views 1 17
Join discussion

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