Post function: "Create Sub task" only works if not edited

Oliver Kurth March 5, 2020

Heya folks!

I kinda have a strange error I can't figure out. I want a sub task with the name of the month to be created based on the value of a custom field. So I created 12 post functions of 4 different kinds checking if the custom field "period" is set to "yearly", "half yearly", "quarterly", "monthly".

So I'm using the 12 post functions with the follwoing conditions and additional actions:

For post function 1,2,4,5,7,8,10,11:

Condition: issue.issueType.name == 'Task' && cfValues['Period']?.value == 'Monthly'

Additional Action: issue.summary = "January - "+sourceIssue.summary

(and same for February, April, May, etc.)

For post functions 3 and 9:

Condition: issue.issueType.name == 'Task' && (cfValues['Period']?.value == 'Monthly' || cfValues['Period']?.value == 'Quartery')

Additional Action: issue.summary = "March - "+sourceIssue.summary

(same for September)

For post function 6:

Condition: issue.issueType.name == 'Task' && (cfValues['Period']?.value == 'Monthly' || cfValues['Period']?.value == 'Quarterly' || cfValues['Period']?.value == 'Half Yearly')

Additional Action: issue.summary = "June - "+sourceIssue.summary

For post function 12:

Condition: issue.issueType.name == 'Task' && (cfValues['Period']?.value == 'Monthly' || cfValues['Period']?.value == 'Quarterly' || cfValues['Period']?.value == 'Half Yearly' || cfValues['Period']?.value == 'Yearly')

Additional Action:

Additional Action: issue.summary = "December - "+sourceIssue.summary

 

 

With that way I have 12 sub tasks being created if "Monthly is select, 4 sub tasks if "Quarterly" is select, 2 for "Half Yearly" and 1 for "Yearly". And each sub task will start with the correct month name.

All the post functions are working. However, now the problem: when I'm editing one of the post functions, even if I'm copy pasting the same code in, they stop working and do not create the sub tasks anymore. This is always only affecting the edited post function. That is very strange and I can't find the reason for it. The only way to get them to work again is, deleting it and then recreating it, which is painful if I want to change something in all 12 post function.

The error I'm getting then is:

2020-03-05 09:21:34,644 ERROR [workflow.AbstractScriptWorkflowFunction]: *************************************************************************************
2020-03-05 09:21:34,652 ERROR [workflow.AbstractScriptWorkflowFunction]: Script function failed on issue: ITIKS-30, actionId: 261, file: null
java.lang.NullPointerException: Cannot get property 'id' on null object

Does anyone have an idea or did encounter a similar problem? We are working with Jira version 7.12.3, which hopefully we will upgrade soon. But not sure if it may be related to that. I'm grateful for any idea :)

 

In the screen below for example I edited function 12, which was working before but since the edit didnÄt work again even if I copy in the old code. The only time it worked again was when it wasn't triggered:

screen2.PNGscreen1.PNG

1 answer

0 votes
Jorden Van Bogaert
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 5, 2020

Hi @Oliver Kurth 

Can you try putting the post functions after "Update Change history for an issue and store the issue in the database" and see if that helps?

Kind regards
Jorden

Jorden Van Bogaert
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 5, 2020

PS: keep the other default items in order, so simply move all the post functions until after the update and store default one

Oliver Kurth March 5, 2020

Heya @Jorden Van Bogaert

Thanks for your reply! I changed the order as suggested (see screenshots 1 & 2). Please let me know, if that order was correct. Then I edited the December post function as it's the easiest to test. I simply added "new" to the string for the summary (screen-3).

Sadly the same error as listed in the original description showed up after the new workflow got published and I tested it (screen-4).

Let me know if I did anything different from what you suggested ;)

Kind regards

screen-1.PNGscreen-2.PNGscreen-3.PNGscreen-4.PNG

Jorden Van Bogaert
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 5, 2020

Hi @Oliver Kurth 

Mm, that's a tricky one. The way you ordered the post function is exactly what I meant :)

I agree that it is a very strange that is happening. If you're showing the full error, I actually think the error comes from the internal code of ScriptRunner. Have you checked whether a bugfix version for the add-on exists? (marketplace is currently down, so you'll have to wait on that to update the add-on).

Sorry I'm not of any more help on this one. :/

Oliver Kurth March 5, 2020

No worries @Jorden Van Bogaert,

Anything we can exclude helps :)

until then I hope, that an update may fix the problem at some point. Just for reference, this is the full error:

Time (on server): Thu Mar 05 2020 11:36:31 GMT+0100 (Mitteleuropäische Normalzeit)

The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.

2020-03-05 11:36:31,077 ERROR [workflow.AbstractScriptWorkflowFunction]: *************************************************************************************
2020-03-05 11:36:31,077 ERROR [workflow.AbstractScriptWorkflowFunction]: Script function failed on issue: ITIKS-30, actionId: 261, file: null
java.lang.NullPointerException: Cannot get property 'id' on null object
 at com.onresolve.scriptrunner.canned.jira.utils.AbstractCloneIssue$_copySystemFieldValues_closure9$_closure13.doCall(AbstractCloneIssue.groovy:438)
 at com.onresolve.scriptrunner.canned.jira.utils.AbstractCloneIssue$_copySystemFieldValues_closure9.doCall(AbstractCloneIssue.groovy:437)
 at com.onresolve.scriptrunner.canned.jira.utils.AbstractCloneIssue.copySystemFieldValues(AbstractCloneIssue.groovy:433)
 at com.onresolve.scriptrunner.canned.jira.utils.AbstractCloneIssue.execute(AbstractCloneIssue.groovy:181)
 at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CreateSubTask.super$4$execute(CreateSubTask.groovy)
 at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CreateSubTask.execute(CreateSubTask.groovy:141)
 at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CreateSubTask$execute.callCurrent(Unknown Source)
 at com.onresolve.scriptrunner.canned.jira.workflow.AbstractWorkflowCannedScript.execute(AbstractWorkflowCannedScript.groovy:17)
 at com.onresolve.scriptrunner.canned.jira.workflow.AbstractWorkflowCannedScript$execute$0.call(Unknown Source)
 at com.onresolve.scriptrunner.jira.workflow.AbstractScriptWorkflowFunction$_run_closure1.doCall(AbstractScriptWorkflowFunction.groovy:93)
 at com.onresolve.scriptrunner.jira.workflow.AbstractScriptWorkflowFunction$_run_closure1.doCall(AbstractScriptWorkflowFunction.groovy)
 at com.onresolve.scriptrunner.runner.diag.DiagnosticsManagerImpl$DiagnosticsExecutionHandlerImpl.execute(DiagnosticsManagerImpl.groovy:325)
 at com.onresolve.scriptrunner.runner.diag.DiagnosticsExecutionHandler$execute$3.call(Unknown Source)
 at com.onresolve.scriptrunner.jira.workflow.AbstractScriptWorkflowFunction.run(AbstractScriptWorkflowFunction.groovy:86)
Like Jorden Van Bogaert likes this
Jorden Van Bogaert
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 5, 2020

I don't see anything actually referring to any of the code you have provided the post function, so I really assume it's going to be within the scriptrunner code itself (but I might be wrong).

The marketplace seems to be running again, so I'd recommend checking for an update of scriptrunner there :)

Oliver Kurth March 5, 2020

Thanks @Jorden Van Bogaert

I will try that. But we have a maintenance and upgrade contract, so the updates of Jira and the add-ons will be planned together to ensure we have compatible versions, so I will need to wait a bit for that.

Anyway, thanks for the time you invested to help me investigating.

Very appreciated :)

Like Jorden Van Bogaert likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events