start date end date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2025 02:46 AM
I would like to implement a restriction where the end date cannot be selected beyond one month from the start date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2025 02:47 AM
then store that in some hidden variable or create a date variable and store there and make it readonly
Then compare the newly selected end date with this and then add validation.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2025 01:10 AM
Hello @dmahendran, I think you can restrict user by creating a business rule to achieve it easily.
you can use following configuration for BR:
- should be before Update
- In the advanced section
write condition as below
!current.end_date.nil() && !previous.end_date.nil() && current.end_date.changes() && current.end_date > previous.end_date
Script as below
(function executeRule(current, previous /*null when async*/ ) {
var newEndDate = new GlideDate(current.u_test_date);
var oldEndDate = new GlideDate(previous.u_test_date);
var diffInMilliseconds = newEndDate.getNumericValue() - oldEndDate.getNumericValue();
var diffInDays = diffInMilliseconds / (1000 * 60 * 60 * 24);
if ( diffInDays > 30 ){
gs.addErrorMessage('Date range is not allowed');
current.setAbortAction(true);
}
})(current, previous);
Regards,
Nishant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2025 11:31 PM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader