Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Limit date selection in date field

vcaracci75
Tera Expert

I would like to set up a date field (variable name: "access_expiration_date") so that if a user tries to select a date greater than six months from the current date, they will get an error message. I would imagine this is an easy script to write, but I'm a fairly new admin and I'm not quite sure how to do it.

Thanks!

Vince

15 REPLIES 15

Hello Harneet, thank you for this post.   I added a new date selection to the "Get Date Filter Options for Date Filters" Business Rule but it did not update the selections within the Between date options.



I added Last 45 Days:   find_real_file.png



But it is not showing up in the date field as an option for between dates.



find_real_file.png



Any thoughts?


As a test, I modified just the txt display field on a working variable and it did not change on the date between selection so I do not believe the "Get Date Filter Options for Date Filters" business rule is the correct rule that controls this.


Harshit,

 

Could you please help with selected date should not exceed maximum 1 year, i have tried all possibilities but didn't worked.

 

Thanks in Advance.

Community Alums
Not applicable

Really helpful Sir...thanks

Lal Singh
Kilo Contributor

Hi,

 

 

In this case UI policy works but instead of selecting quarter, you need to user relative function and condition should be like if 

When to apply

This is to check if date is exceeding 6 month

Date ->Relative->after->180 ->days->fromNow

OR

Date ->Relative->after->3->Month->fromNow

 

In the script you can alert

alert('End date cannot be more than 6 months from current date');