Forums

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

Date validator (30 days) - JMWE

RIZKY JTUASIKAL
Contributor
May 25, 2023

Example:

Today is 05/25/2023 and if I create a task on 06/26/2023 (30 days) it will show an error message,

and if I create a task between the interval on 05/25/2023-06/25/2023 there is no error and the task is being created.

 

What is the query to get that result??

and what type of validator can I use??

1 answer

1 accepted

0 votes
Answer accepted
David Fischer
Community Champion
May 25, 2023

Hi @RIZKY JTUASIKAL ,

what do you mean by "I create a task on 06/26/2023"? Where is that date input? In a custom field?

RIZKY JTUASIKAL
Contributor
May 25, 2023

Hi @David Fischer ,

it doesn't use custom field/date input. 

is that possible?



or does it have to use date input?

 

 

please advice,

 

thank you David 

RIZKY JTUASIKAL
Contributor
May 25, 2023

Example:


I created subtask A, and will record the creation date.

Created on 05/25/2023.

 

Then there is a rule if it is still within 30 days (bases on the date of subtask A creation),

I can still create another subtask,

(ex: subtask B)

 

 

but, if it exceeds 30 days, I can't create subtask B

David Fischer
Community Champion
May 26, 2023

So to summarize:

  1. you create a main issue
  2. you create a first sub-task on that issue
  3. when you attempt to create a second sub-task on that issue, you want to disable the creation if the first sub-task was created more than 30 days earlier
  4. when you attempt to create additional sub-tasks, you want to disable the creation if the oldest sub-task was created more than 30 days earlier

Is that correct?

Like RIZKY JTUASIKAL likes this
RIZKY JTUASIKAL
Contributor
May 26, 2023

Yes, it's correct.

Everything you described above is correct, @David Fischer :)

David Fischer
Community Champion
May 26, 2023

Hi @RIZKY JTUASIKAL ,

in that case, you can use a Build-your-own Validator with this Jira Expression:

!issue.parent || !issue.parent.subtasks.some(sub=>sub.created < new Date().minusDays(30))
RIZKY JTUASIKAL
Contributor
May 28, 2023

Hi @David Fischer ,

 

" when you attempt to create a second sub-task on that issue, you want to disable the creation if the first sub-task was created more than 30 days earlier "

what if these two subtasks are different issue types and workflows?

Ex:

subtask 1 is "Release Project"

subtask 2 is "Release PIR"

does it mean that I have to create a validator in the create transition (in Release PIR workflow)?

create.PNG
so that subtask 2 cannot be created if it exceeds 30 days





for addtional information,

I use the Release Project - Created Date field as the reference date.

release date created date.PNG

 

This field (Release Project - Created Date) is the date when subtask 1 was created. 

David Fischer
Community Champion
May 28, 2023
  1. Yes, you need to add the Validator on the Create transition of the sub-task workflow(s)
  2. With my script, you don't need to refer to the Prelease Project - Created Date since the script looks at all sub-tasks and their creation date
Like RIZKY JTUASIKAL likes this
RIZKY JTUASIKAL
Contributor
May 28, 2023

Thank you @David Fischer , for the answers

I really appreciate it

 

 

but one more question,

"With my script, you don't need to refer to the Prelease Project - Created Date since the script looks at all sub-tasks and their creation date"

what if only one of the subtasks?
for example, Release PIR subtask only

David Fischer
Community Champion
May 29, 2023

Then you can use your custom field instead:

!issue.parent || !issue.parent.customfield_12345 || issue.parent.customfield_12345 >= new Date().minusDays(30)

where customfield_12345 is the custom field ID of the Release Project - Created date custom field.  

Like RIZKY JTUASIKAL likes this
RIZKY JTUASIKAL
Contributor
May 29, 2023

thank you David :)

you help me so much

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