Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner: issue with Transition parent when all sub-tasks resolved

Aleksei Klimkin
Contributor
December 4, 2019

Hi everyone.

We have scriptrunner and use its post-function named "Transition parent when all sub-tasks are resolved".

The final status after parent's transition is not a final status in the workflow, meaning we don't need to set the resolution on the parent. Or, to be more precise, we need to leave it unresolved.

However, when I use the aforementioned post-function (I only choose the necessary transition, without setting any conditions, and leave the "Resolution" field value None) I get this error and it doesn't allow me to update the function.

What could be the problem with that?

Thanks in advance!

resolution not set error.png

2 answers

0 votes
Leonard Chew
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.
December 5, 2019

Resolution "None" should be correct in my opinion, but if you are forced to set a value on that screen, this might be a workaround:

  1. select any other resolution for the postfunction to work
  2. add a "clear resolution" with a postfunction on the transition of the parent
    clearResolution.png

Alternatively:

  • Try a custom script on your postfunction and script the transition without setting the resolution.
Leonard Chew
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.
December 5, 2019

Before trying the above... check if you have configured a transition screen with a mandatory resolution field.

Aleksei Klimkin
Contributor
December 5, 2019

Yes, I thought about that too.

I am afraid this might cause side-effects too. For example, if you're using some filter to find issues resolved in the last week, this workaround might cause the issue to appear in that search because the resolution for that issue was set during last week.

Thought I haven't tried this yet.

Aleksei Klimkin
Contributor
December 5, 2019

No, the transition 81 for the parent uses no screen.

Roberto Marquez Bittencourt April 2, 2020

Something new about that? I have the same error. I've updated the Script Runner version in our test enviroment and have the same results.

Thanks,

Roberto Bittencourt

Aleksei Klimkin
Contributor
April 3, 2020

Still doesn't work.
I've had to write my own script for this transition.
Perhaps you may find it useful.

import com.atlassian.jira.workflow.*
import com.atlassian.jira.util.JiraUtils
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor

def wtu = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class)

def userKey = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getKey()

def parent = issue.getParentObject()
def subtasks = parent.getSubTaskObjects()
def categories = subtasks*.status.statusCategory

if (parent.getStatus().getSimpleStatus().getName() == "In Progress" &&
    categories.every {cat -> cat.getName() == "Complete"}) {

       def mp = parent as MutableIssue

       wtu.setIssue(mp)
       wtu.setUserkey(userKey)
       wtu.setAction(81)

       if (wtu.validate()) {
            wtu.progress()
       }
}

This is the script which transitions parent issue from status "In Progress" through the transition with id 81 when the status category for all sub-tasks is "Complete", i.e. work finished.
Of course you need to adjust it a little bit based on your needs.

Like Nicolas Desessart likes this
0 votes
Damian Wodzinski
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.
December 4, 2019

Is the "None" the correct resolution? Maybe try to pick "Unresolved" from the list?

Aleksei Klimkin
Contributor
December 5, 2019

resolution values.png
Unfortunately, there's no Unresolved in there

Damian Wodzinski
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.
December 5, 2019

I think somebody designed it that way. Maybe try workaround? Add another status matching the state if the parent: "Subtasks done", or simply add "Unresolved", but this may cause some confusion when trying to search using JQL, as there will be two of the same resolutions.

Aleksei Klimkin
Contributor
December 5, 2019

Well, actually nope, because it was working fine previously. I don't even know when it started showing this error, to be honest.

Well, adding another resolution seems a bit worrying for me, since there're a lot of filters used in jira for this purpose, and basically Unresolved means that resolution is not set for the issue.

So if I set the Resolution to this new "Unresolved" I am afraid that it might cause side-effects.

The most important question is why is this now not working though it used to work in the past.

Hope to get some response from Adaptivist ScriptRunner members.

Aleksei Klimkin
Contributor
December 5, 2019

Anyway, thanks for your help!

Damian Wodzinski
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.
December 5, 2019

You should also check the project settings to see, if "Resolution" field is required. Maybe it's blocking you there.

Suggest an answer

Log in or Sign up to answer