How do i set up a specific lead time for normal change requests?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2016 04:57 AM
In our Dev Instance I have created a business rule that warns people if they do not schedule an appropriate level of lead time on a normal change request. Potentially I may have to make it so our users can't request approval / submit a change request unless the lead time has been met. I have checked through the forums as there are plenty of similar threads but none that seem to specifically give me the direction to go in.
Simply, I would like; Normal Change request can not be submitted unless 1 week (or 5 business/working days) lead time has been adhered to in the planned start/end dates.
Many thanks in advance
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2016 05:06 AM
Hi Steven,
I believe the scheduled date for the Change request would be stored in the Planned Start date on the Change Request form.
So in this case you can have a onSubmit Client Scirpt which passes the Start date (Date & time of CR submission) and the End date (Planned Start Date of CR) to the DurationCalculator Script Include to calculate the difference between these two dates.
If the returned value from the Script Include is less than 5 Business days, then you can return false and abort submission.
You can also pass a schedule to the DurationCalculator Script Include to check the Business duration. Refer DurationCalculator - ServiceNow Wiki
Thanks and Regards,
Aswin Siddalingam

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2016 05:08 AM
Hi Steven,
It's really pretty simple using the GlideDateTime methods, addDays() and getNumericValue() to compare. Here's a little script I whipped up in scripts background to demonstrate. You should be able to adapt it quite easily to your fields (already of GlideDateTime format) to do the comparison.
var startStr = '2016-07-27 11:00:00'; // Some arbitrary date - change it to test this script below
var now = new GlideDateTime(); // current date/time
var start = new GlideDateTime(startStr); // Simulated field value
gs.print('now=' + now.getNumericValue()); // debug statement
gs.print('start=' + start.getNumericValue()); // debug statement
now.addDays(7); // Add 7 days to the current date value
gs.print('now+7=' + now.getNumericValue()); // debug statement
if (now.getNumericValue() >= start.getNumericValue()) // do the real check - is 7 days from now enough time?
gs.print('Not enough lead time');
else
gs.print('Thank you for the lead time');