The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

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. :)

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events