Changing Parent Status based on sub-task status.

Allan Nunez February 22, 2018

Wrote the code as a post function on the workflow. Its supposed to be a simple check of the parents Status. If the status matches then it should return true and execute.

For some reason I can't even get passed the issue class. I tried running in Scriptrunner Console but get an error on the issue class. Here is the code:

import com.atlassian.jira.issue.Issue
Issue issue = issue
 
if(issue.parentObject.status.name == "To Do" || issue.parentObject.status.name == "Refinement" || issue.parentObject.status.name == "Ready to Work")
{
    return(true);
}
else
{
    return(false);
}

Error

No such property: issue for class: Script263

groovy.lang.MissingPropertyException: No such property: issue for class: Script263
at Script263.run(Script263.groovy:2)

1 answer

0 votes
Jenna Davis
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 14, 2018

Hello, 

Sorry for such a late reply on this!

You shouldn't need to define issue for a post function. Try just doing:

if(issue.parentObject.status.name == "To Do" || issue.parentObject.status.name == "Refinement" || issue.parentObject.status.name == "Ready to Work")
{
    return(true);
}
else
{
    return(false);
}

As far as running this in the Script Console, you need to define what issue your trying to run the script on there. You can use a method from the IssueManager class to get an issue by it's key and then run a script in the console off of that. 

Please let me know if this works for you, or if you have any other questions. :)

Jenna 

Allan Nunez March 15, 2018

Still not working, we added a Groovy post function "Transition current issue's parent issue. "  on the "Working" Transition step. The idea is to have the issues Parent move to "Working" Status only if its current status is in Refinement, ready to work or To do. in the post function we added the code above. When we move a sub task to the "Working" step the Parent issue does not change.

Any thoughts?

Thank you.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events