Date Time Validator - JMWE
Asked by RIZKY JTUASIKAL:

I have a Date Time field,

![Date Validator.PNG](/t5/image/serverpage/image-id/275376i08CAB855557A8620/image-dimensions/238x48?v=v2 "Date Validator.PNG")

and another field called Notes,  

![Capture.PNG](/t5/image/serverpage/image-id/275377i7BBB7BABA43F22AF/image-dimensions/305x81?v=v2 "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


Answers:
author: Avinash Bhagawati _Appfire_
body: Hi [@RIZKY JTUASIKAL](/t5/user/viewprofilepage/user-id/5191649) ,  

With the help of [Field Required Validator ( JMWE)](https://appfire.atlassian.net/wiki/spaces/JMWEC/pages/78481806?atlOrigin=eyJpIjoiZTM0NGFlZGI5ODQxNDE1ZDgwZmYzNzZkYTFhZGUyODAiLCJwIjoiYyJ9) 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](https://community.atlassian.com/t5/image/serverpage/image-id/275391i9652AD0B262CCB38/image-size/large?v=v2&px=999 "2023-08-16_13-30-39.png")

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

Thanks,  
Avinash

comments: author: RIZKY JTUASIKAL
body: Hi Mr. [@Avinash Bhagawati _Appfire_](/t5/user/viewprofilepage/user-id/3491119) ,

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](https://community.atlassian.com/t5/image/serverpage/image-id/275400iE3C3C0E86CA25DDF/image-size/large?v=v2&px=999 "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..


author: Avinash Bhagawati _Appfire_
body: Hi [@RIZKY JTUASIKAL](/t5/user/viewprofilepage/user-id/5191649) ,

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


author: RIZKY JTUASIKAL
body: Hi Mr. [@Avinash Bhagawati _Appfire_](/t5/user/viewprofilepage/user-id/3491119) ,

Here's the result

![Capture.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/275418iB3F62AD657798144/image-size/large?v=v2&px=999 "Capture.PNG")

I hope this helps :)


author: Avinash Bhagawati _Appfire_
body: Thanks, [@RIZKY JTUASIKAL](/t5/user/viewprofilepage/user-id/5191649) , 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


author: RIZKY JTUASIKAL
body: Hi Mr. [@Avinash Bhagawati _Appfire_](/t5/user/viewprofilepage/user-id/3491119) ,

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


author: Avinash Bhagawati _Appfire_
body: That's great [@RIZKY JTUASIKAL](/t5/user/viewprofilepage/user-id/5191649) ! Glad to know that provided solution works for you!


Tags: addon-com.innovalog.jmwe.jira-misc-workflow-extensions

cloud

confluence-cloud