Forums

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

Date Time Validator - JMWE

RIZKY JTUASIKAL
Contributor
August 16, 2023

I have a Date Time field,

Date Validator.PNG

and another field called Notes,

Capture.PNG

 

I wanted to ask,

how to do, so that when the Date Time field is filled on the 20th - the end of the month (calendar time), then the Notes field will become mandatory

 

Thanks a lot in advance 

1 answer

1 accepted

0 votes
Answer accepted
Avinash Bhagawati {Appfire}
Community Champion
August 16, 2023

Hi @RIZKY JTUASIKAL ,

With the help of Field Required Validator ( JMWE) and below conditional validation code you will be able to achieve your requirement.

1. Navigate to the required transition and click on validator to add.

2. Select Field Required Validator (JMWE) and select the Notes field in the dropdown.

3. Check the Conditional Validation and add the below code. 


!! issue.customfield_10015 && (((issue.customfield_10015 ? new CalendarDate(issue.customfield_10015) : null).getDate() >= 15) && ((issue.customfield_10015 ? new CalendarDate(issue.customfield_10015) : null).getDate() <= 31))

4. In the above code, please replace 10015 with the custom field id of the plan implementation date field.

Please find below a sample screenshot for your reference.

2023-08-16_13-30-39.png

Please try with the above configuration and please let me know how it goes.

Thanks,
Avinash

RIZKY JTUASIKAL
Contributor
August 16, 2023

Hi Mr. @Avinash Bhagawati {Appfire} ,

 

thank you for providing a detailed answer :)

but when I tried the query given by you earlier, I got an error message like this:error.PNG

and here is my query:

!! issue.customfield_12611 && (((issue.customfield_12611 ? new CalendarDate(issue.customfield_12611) : null).getDate() >= 15) || ((issue.customfield_12611 ? new CalendarDate(issue.customfield_12611) : null).getDate() <= 31))

 

_12611 is the field Plan Implementation Date (date time)

 

and there's something I want to ask, regarding this:
"getDate() >= 15)"

do I need to change 15 to 20 or not?

 

 

 

I truly appreciate your help..

Avinash Bhagawati {Appfire}
Community Champion
August 16, 2023

Hi @RIZKY JTUASIKAL ,

Thanks for your response on this.

Please test the code below on sample issue key to see what it returns for further troubleshooting.


issue.customfield_12611

 On the below query, yes, you can replace 15 with 20. 

and there's something I want to ask, regarding this:
"getDate() >= 15)"

do I need to change 15 to 20 or not?

Thanks,
Avinash 

RIZKY JTUASIKAL
Contributor
August 16, 2023

Hi Mr. @Avinash Bhagawati {Appfire} ,

 

Here's the result

Capture.PNG

I hope this helps :)

Avinash Bhagawati {Appfire}
Community Champion
August 16, 2023

Thanks, @RIZKY JTUASIKAL , that helps here. 

You use the Date time picker field instead of a Date picker field. Above provided code works for only the Date Field type.

Please find below the code for the Date time picker field.



!! issue.customfield_12611 && ( new Date(issue.customfield_12611).toCalendarDate().getDate() >= 20 && new Date(issue.customfield_12611).toCalendarDate().getDate() <= 31)

 

Please try with the above code and please let me know if you have any additional questions.

Thanks,
Avinash

Like RIZKY JTUASIKAL likes this
RIZKY JTUASIKAL
Contributor
August 18, 2023

Hi Mr. @Avinash Bhagawati {Appfire} ,

 

I'm sorry, yesterday was our day off...

 

and today, just able to test again, and the query you provided works very well. :)

 

 

thank you very much for your help, Sir..

Avinash Bhagawati {Appfire}
Community Champion
August 18, 2023

That's great @RIZKY JTUASIKAL  ! Glad to know that provided solution works for you!

Like RIZKY JTUASIKAL likes this

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