Forums

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

Validator to check if three subtasks were created after a field date

Michael Dixon August 18, 2023

Hello,

We'd like to create a validator to check if three subtasks of issue type "Contact" were created after a date in a custom field. Does anyone know if this is possible using JMWE?

For example:

If 3 subtasks of type "Contact" created after Aug 15th then allow the transition.

 

I know that it's possible to check the creation date of a subtask before allowing parent to transition, but not sure how to check for multiple of the same type.

 

Thank you for your responses!

2 answers

1 accepted

2 votes
Answer accepted
David Fischer
Community Champion
August 18, 2023

Hi @Michael Dixon 

if I understand correctly, you'd like to allow a transition only if at least 3 sub-tasks of the current issue were created after a date stored in a custom field of the current issue. Is that correct?

If so, you can use a Build-your-own condition or validator (depending on whether you want the transition to disappear or just show an error message when the transition is triggered), and use a script like:

issue.subtasks.filter(it => it.created >= new Date(issue.customfield_12345)).length >= 3

where  customfield_12345 is the custom field ID of the Date/Time Picker custom field that holds the date. If that custom field is a Date Only Picker, use this code:

issue.subtasks.filter(it => it.created.toCalendarDate() >= new CalendarDate(issue.customfield_12345)).length >= 3
0 votes
Kian Stack Mumo Systems
Community Champion
August 18, 2023

@Michael Dixon

 

Could you try something like this?

 

 !!issue.subtasks && !issue.subtasks.some(it => it.created.toCalendarDate() <= issue.dueDate)

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