Forums

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

JMWE Validator to check for subtask status based on Summary value

Robert Mein February 7, 2023

We auto generate some subtasks (for demo we'll say the Summary for each is Subtask A, Subtask B, and then Subtask C.  During some transitions we want to check to see if the specific subtask is Closed.  

Using the JMWE Linked Issues Status validator and need to add a conditional validator.  I have the following to see if a subtask exists with that summary but need to also check the status of that specific subtask.

!!issue.subtasks && issue.subtasks.some(it => it.summary == "Subtask A")

 

Perhaps a Build Your Own Validator makes more sense.

1 answer

1 accepted

2 votes
Answer accepted
David Fischer
Community Champion
February 8, 2023

Hi @Robert Mein ,

you can use the Build Your Own (scripted) validator with this script:

!issue.subtasks || !issue.subtasks.some(it => it.summary == "Subtask A" && it.status.name != "Closed")

which will return true (transition is valid) if either there is no subtask or if there is no subtask whose summary is "Subtask A" and whose status is not Closed.

To better understand it, consider the negation of the validator: it will fail (show an error) if there is a subtask whose summary is "Subtask A" and whose status is not Closed, and succeed in all other cases.

Robert Mein February 8, 2023

Thank you!  This is very helpful.  How would I use StatusCategory.name instead of status.name?  We have some Final statuses that are not "Closed" and I'd like to account for that as well.  I tried this but no success

!issue.subtasks || !issue.subtasks.some(it => it.summary == "Subtask A" && it.statuscategory.name != "Done")

 

 

EDIT:
I think I figured it out: && it.status.category.name != "Done") 

Robert Mein March 28, 2023

@David Fischer 

New question that is a slight variation of this:

 

I have 5 subtasks (for our purposes the summaries are "Subtask A", "Subtask B", etc.).  When subtasks B, C, and E are transitioned to in-progress, I'd like to validate that the original estimate field is >0.

This is what I have and it works for those three subtasks but fails on the Subtask A and D


(issue.summary == "Subtask B" || issue.summary == "Subtask C" || issue.summary == "Subtask E") && issue.originalEstimate >0

David Fischer
Community Champion
March 28, 2023

Hi @Robert Mein 

that's because you need to think in terms of what makes the validator pass. It should pass when the summary is not Subtask B or C or E, or (if it is), if the originalEstimate is > 0. Therefore:

(issue.summary != "Subtask B" && issue.summary != "Subtask C" && issue.summary != "Subtask E") || issue.originalEstimate >0
Like Robert Mein likes this

Suggest an answer

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

Atlassian Community Events