- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2017 06:25 AM
I have been tasked with configuring a field in change management to bounce up against black out dates. I know the system currently allows blackout dates, However, you need CI's to be used, and we have not reached that yet. I was wondering if someone has, or if there is a way, to go up against the ServiceNow Calendar for field validation?
Either one of 2 options
Option 1.
When user clicks on the calendar icon for "Planned start date" within Change, the calendar would refuse/black out any dates that are marked in the calendar as black out.
Option 2.
After selecting the "Planned start date", bounce it against the calendar to check if that date/time is blacked out?
Thanks
David.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2017 06:58 AM
Probably the most straightforward solution would be to warn the user when they pick a date that is in the blackout schedule. You can achieve this using a client callable script include. If you are unfamiliar with this, you should look over the documentation provided by ServiceNow:
To check a date against a schedule is pretty easy. All you need is the sys_id of the schedule you are checking against and the date you want to check. Here is a sample script that you can use in Scripts - Background to validate:
var chkDate = '2017-11-21 12:00:00';
var schedID = ''; //Put the sys_id of your blackout calendar within the quotes;
var chk = isWithinSched(chkDate, schedID);
gs.print(chk);
function isWithinSched(dateTime, schedID) {
// isWithinSched: function(dateTime, schedID) {
var sched = new GlideSchedule(schedID);
var chkDT = new GlideDateTime(dateTime);
return (sched.isInSchedule(chkDT));
// },
}
If you want to use the function within your script include, you can format the function using the commented out lines.
I hope this is helpful,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2017 06:52 AM
Hi David,
I think 2nd option is more viable.
You can write after insert business rule on change table, pick the planned date and check its value among blackout dates,
if its presence there you can set the action to abort and pass on a custom message for the user to select some other value.
Please mark the response correct/helpful based on the impact.
Thanks
Gaurav

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2017 06:58 AM
Probably the most straightforward solution would be to warn the user when they pick a date that is in the blackout schedule. You can achieve this using a client callable script include. If you are unfamiliar with this, you should look over the documentation provided by ServiceNow:
To check a date against a schedule is pretty easy. All you need is the sys_id of the schedule you are checking against and the date you want to check. Here is a sample script that you can use in Scripts - Background to validate:
var chkDate = '2017-11-21 12:00:00';
var schedID = ''; //Put the sys_id of your blackout calendar within the quotes;
var chk = isWithinSched(chkDate, schedID);
gs.print(chk);
function isWithinSched(dateTime, schedID) {
// isWithinSched: function(dateTime, schedID) {
var sched = new GlideSchedule(schedID);
var chkDT = new GlideDateTime(dateTime);
return (sched.isInSchedule(chkDT));
// },
}
If you want to use the function within your script include, you can format the function using the commented out lines.
I hope this is helpful,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2017 06:32 AM
Hi Chris,
Thanks, I got our Dev's to finally help with this. We believe we got it working. However, there appears to be a timezone issue. However, I set the schedule to CST and my timezone (for my account) is CST. However, it is not behaving correctly. Currently we are utilizing an alert message box. If there is a better way of displaying the message please let me know.
I have a scheduled "Change Blackout" that has a blackout for 12-15-2017 to 01-15-2018 with all day checked (tried it with hrs and still doesn't work)
I enter in a change for 12-15 for 5pm and get no popup.
I update the change to 6pm and get the popup.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2017 06:48 AM
Please provide some screen shots of what you have configured (Schedule, Scripts, etc) so we can evaluate what is occurring.