How to disable days from being selected on the Date/Time Datepicker field

craig_attersall
Kilo Contributor

When I requested a patch on Service-Now HI that required a version entitlement request, I was presented with a Date/Time Datepicker field to schedule the patch. On this field I could not select a date in the past or 3 days in the future (3 days for the version entitlement request).

See below, the 2 Aug was the first date that I could select.
Datepicker with disabled days.png

Does anyone know how they did this?

I know you can produce alerts if you select a past date, like this http://wiki.servicenow.com/index.php?title=Verify_Request_Start_and_End_Dates, but how do you grey-out the past dates so they can't be selected?

7 REPLIES 7

Oh , that's not a problem, thx


craig_attersall
Kilo Contributor

I am experiencing a different behaviour, for example;


Today is 24/8/15. I logged into HI, under manage upgrades I selected Fuji Patch 7 Hot Fix 1. I get a message stating that this version requires an entitlement approval and that I must choose a date at least 3 days from today.


In the date time picker window, as expected, the numbers of the days from the past month are grey, and the numbers of the days in the current month are black.


However (the behaviour that I'm looking for is this bit), the 28th has been selected by default and highlighted grey, if I click the 29th that becomes grey. All the days less than today+3 are coloured in red. If I hover my mouse over those dates in red, I get the pointer icon and I literally cannot click any of them. If I hover my pointer over any of the future dates, my pointer changes to the hand with the pointing index finger and I can click them and move the highlighted grey box.


hi-calendar-28.PNGhi-calendar-29.PNG


Hi Craig,



I see what you're talking about. The entitlement/upgrade page has been extensively rewritten since I last worked on it. It used to be a record producer, but now is a custom UI Page. In that custom UI Page, the Hi devs are using a custom class that is based on the Date/Time picker, but has additional capabilities. They aren't using the standard date/time element.



The customization they are using is fairly extensive. I've attached the script (which you can also get by viewing the source on that page). You may be able to write a custom macro and add it as a field decoration on your date fields. It is not a simple copy/paste procedure, but it should be doable.