Forums

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

[JMWE] Compare the current date (system date) with a date field

RIZKY JTUASIKAL
Contributor
February 19, 2024

When we want to submit a status, from status A to status B, there is a validation to compare the current date (the day the status was submitted) and the value of the MoA Signed Date field.

- If the current date is less than 3 months from the MoA Signed Date, then JIRA can be submitted.

- If the Current Date is more than 3 months from the MoA Signed Date, then JIRA fails to submit and an error message appears.

 

is there a simple way to get this validation? (maybe using the Date Compare Validator feature?) or do you have to use the following features: Build-your-own (scripted) Validator (JMWE app)?

please help, and thanks in advance

1 answer

1 accepted

3 votes
Answer accepted
David Fischer
Community Champion
February 19, 2024

Hi @RIZKY JTUASIKAL 

you can easily implement this using JMWE's Build-your-own (scripted) Validator, using a script like this:

new Date().toCalendarDate() <= issue.customfield_12345.plusMonths(3)

where  customfield_12345 is the custom field ID of field MoA Signed Date. This assumes that MoA Signed Date is a Date Only custom field. If it's a Date/Time field, the script would be:

new Date() <= issue.customfield_12345.plusMonths(3)
David Fischer
Community Champion
February 19, 2024

Hi @RIZKY JTUASIKAL 

Did this work for you? If so, could you please "accept" the answer so others can find it?

RIZKY JTUASIKAL
Contributor
February 19, 2024

Hi @David Fischer ,

thank you very much for helping me answer my question.

 

I have tried the way you told me, using the following query:

new Date().toCalendarDate() <= issue.customfield_12927.plusMonths(3)

 

because the MoA Signed Date field is a Date Picker.

and issue.customfield_12927 is MoA Signed Dated ID 

 

But I got an error message like this:

Capture.PNG

David Fischer
Community Champion
February 19, 2024

Hi @RIZKY JTUASIKAL 

My bad, I forgot that a custom field of that type returns a string. Try this:

!!issue.customfield_12927 && new Date().toCalendarDate() <= new CalendarDate(issue.customfield_12927).plusMonths(3)
RIZKY JTUASIKAL
Contributor
February 20, 2024

Hi @David Fischer ,

 

For the query you provided, it works like a charm. 

Thank you for your help, God bless you, and your family. :)

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