We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Disabling dates in calendar/date field

lpolicarpio
Tera Contributor

Hi team,

 

We have a requirement to make some dates unselectable or greyed out in the date field. Is it this possible to do in ServiceNow? Do we need a custom widget for it? Any ideas/references will be greatly appreciated. 

 

Thank you!

2 REPLIES 2

Dinesh_Now
Tera Contributor

Hello @lpolicarpio ,

You can refer below similar to same.

https://www.servicenow.com/community/developer-articles/no-code-date-validations-through-catalog-ui-...
https://www.servicenow.com/community/service-management-forum/how-to-disable-the-dates-in-calender-f...
https://www.servicenow.com/community/service-management-forum/how-to-disable-the-dates-in-calender-f...

---------------------------------------------------------------------------------
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

lauri457
Tera Sage

It is not possible with just "configuration" but it is customizable which you might want to avoid. It also requires understanding a little bit about angularjs and how it works in the portal. 

 

You can use angularjs decorators to redefine the link function for the directive to change the configs that the oob datetime variable doesn't expose. Or you can for example copy the existing datetime directive to create an angular provider that you can then use as an element directive on your custom widget. With a widget variable you will have to create another variable to store the value.

 

Here is the datetime variable with a side by side view and a min and max date

var config = {
	format: format,
	locale: spUtil.localeMap[g_lang],
	language: spUtil.localeMap[g_lang],
	maxDate: moment("2026-02-18"),
	minDate: moment("2026-02-10"),
	sideBySide: true,
};

asdadsd.png

 

 

Here's a write up of how to use decorators

Decorating OOB angularjs directives - ServiceNow Community

Docs for the timepicker:

https://getdatepicker.com/5-3/