- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 12-21-2020 05:01 AM
fix script to do lead time calculation, This can be used in a script include and called via client script by passing right variable values.
This script compares date diff between planned start date, current date using a schedule of your choice.
var sLog = '';
var isValid = false;
var plannedStartDate = new GlideDateTime();
plannedStartDate = getStartDate();
var dc = new DurationCalculator();
dc.setSchedule('7808de182f91e850f101ad2ef699b659' ); // schedule of CAB
var gdt = new GlideDateTime();
if(dc.calcScheduleDuration(gdt,plannedStartDate) >0) {
isValid = true;
}
sLog = "start Date =" + plannedStartDate;
sLog+= " Current Date= " + gdt;
sLog += " Is Date Valid =" + isValid;
gs.print(sLog);
function getStartDate() {
var grChg = new GlideRecord('change_request');
grChg.get('7557790f378c1300023d57d543990ed5');
return grChg.start_date;
}
Youtube link with explanation of script
ServiceNow change management - CalculateChangeLeadTime - YouTube
Updateset is available here https://developer.servicenow.com/connect.do#!/share/contents/3287388_fix_script_to_calculate_difference_between_planned_start_date_and_current_date_of_a_change_request?t=PRODUCT_DETAILS
- 1,930 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Ty Tiago 🙂