Problem creating sub-task through parent workflow with script runner

I have a project in which for a certain issue type, in his workflow, I create a Script Post-Function of type 'Create a sub-task' in his create transition.

In the configuration, I set the 'Target Issue Type' and a summary for the subtask, that's all.

When I create the parent issue, and the script runs, the subtask is not created, and this is the error message shown in the log:

2015-02-06 11:58:49,171 http-bio-8080-exec-9 WARN JPulgarinB 718x11221x2 1igg7m8 172.28.110.62,127.0.0.1 /secure/QuickCreateIssue.jspa [jira.workflow.postfunctions.CloneIssue] Could not set security level, as the schemes between the two projects are different.
2015-02-06 11:58:49,207 http-bio-8080-exec-9 ERROR JPulgarinB 718x11221x2 1igg7m8 172.28.110.62,127.0.0.1 /secure/QuickCreateIssue.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] *************************************************************************************
2015-02-06 11:58:49,210 http-bio-8080-exec-9 ERROR JPulgarinB 718x11221x2 1igg7m8 172.28.110.62,127.0.0.1 /secure/QuickCreateIssue.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: null, actionId: 1, file: null
java.lang.NullPointerException
        at com.atlassian.jira.issue.customfields.impl.SelectCFType.getDefaultValue(SelectCFType.java:244)
        at com.atlassian.jira.issue.customfields.impl.SelectCFType.getDefaultValue(SelectCFType.java:69)
        at com.atlassian.jira.issue.fields.CustomFieldImpl.getDefaultValue(CustomFieldImpl.java:1248)
        at com.atlassian.jira.issue.IssueImpl.getCustomFieldValue(IssueImpl.java:1007)
        at com.atlassian.jira.issue.IssueImpl.setCustomFieldValue(IssueImpl.java:1016)
        at com.atlassian.jira.issue.MutableIssue$setCustomFieldValue$2.call(Unknown Source)
        at com.onresolve.scriptrunner.canned.jira.utils.AbstractCloneIssue$_copyCustomFieldValues_closure3.doCall(AbstractCloneIssue.groovy:141)
        at com.onresolve.scriptrunner.canned.jira.utils.AbstractCloneIssue.copyCustomFieldValues(AbstractCloneIssue.groovy:133)
        at com.onresolve.scriptrunner.canned.jira.utils.AbstractCloneIssue.doScript(AbstractCloneIssue.groovy:62)
        at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CreateSubTask.super$2$doScript(CreateSubTask.groovy)
        at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CreateSubTask.doScript(CreateSubTask.groovy:120)

 

Any ideas of what is happening??

By the way, when I have a parent issue and create the subtask manually, it is created without any problem.

3 answers

The order may be wrong. Make sure that your post function is after the creation of the issue.

In doubt put it at the end.

Screen Shot 2015-02-09 at 13.07.36.png

No, that's ok, I put it after the re-index post function, this is not the first time I create a sub-task this way, actually, I did the same in other jira environments, and is working ok, the subtask is created, but in the jira instance that I'm doing it, is showing that error in the log, and the subtask in not created.

Could you please add some details about the code you are using to create the subtask?

It seems that you have a null parent issue when you are going to create the subtask.

Hi Cesare, I'm not using any code at all, just the workflow post-function.
I have a project configured with some issues and subtask, and in the workflow of a parent issue, in the create transition, I just add a post function of type 'Create a sub-task', where I choose the issue type for that subtask, and give a text for the summary, that's all.

config.jpg

I tried the same in another project, with another issue type and workflow, but the problem is the same.

Which version of Script Runner do you have?

The last one, 3.0.10. But that's not the problem, as I said before, in another testing environment works ok, but in production and other testing environments, is not working, I think there's a problem with the data of those environments that makes conflict with some script runner code.

The problem seems to be related to one of the select/multiselect/radio/checkbox fields on the parent issue, that is also on the child issue. Are there any like this?

we tried to reproduce this actually... can you try in a different workflow/project or something so we can rule things out?

or you can create an issue at https://jamieechlin.atlassian.net/browse/GRV and get us a backup of your db if you're desperate.

I did those tests some days ago, I just created a new project for this, just with summary assignee and description, same for the child, and the problem was the same, that's the reason I asked you :) , cause that was very strange

I cannot give a backup of the db because of the information that the company works with.

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 Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

119 views 0 5
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