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.
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.
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")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.