Forums

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

ScriptRunner Validator that checks Parent Issue Status

Tom Yan April 5, 2024

I would like to add a Validator on the Create transition of a Story that prevents the user from creating the Issue if A) the Parent field is empty, or B) if the Parent Issue status is "Done". 

I have tried this ScriptRunner script, but it is not being triggered, and the validation automatically returns false:

if (issue.parent != null) { 

return issue.parent.status.name != 'Done';

} else {

return false;

}

Any tips would be appreciated!

Thank you

 

1 answer

0 votes
Fabio Racobaldo _Herzum_
Community Champion
April 7, 2024

Hi @Tom Yan ,

please try the following code :

 

 

if(issue.getParentObject()!=null) {

return "Done".equalsIgnoreCase(issue.getParentObject().getStatus().getName());

} else

return false;

 

Hope this helps,

Fabio

Tom Yan April 8, 2024

@Fabio Racobaldo _Herzum_ 

I am still receiving this error message when the Validator is triggered with the above code:

"timestamp": "2024-04-08T17:44:17.094Z", 
"webhookEvent": "jira_expression_evaluation_failed",
"expression": "if(issue.getParentObject() != null) {\r\n return \"Done\".equalsIgnoreCase(issue.getParentObject().getStatus().getName());\r\n} else {\r\n return false;\r\n}\r\n",
"errorMessages": [ "Evaluation failed: \"issue.getParentObject\" - Unrecognized property of `issue`: \"getParentObject\" ('getParentObject'). Available properties of type 'Issue' are: 'assignee'

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events