- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 03-03-2020 11:16 AM
When implementing Change Management you're always going to need to calculate Lead Time for a Change to be implemented.
Lead Time means how much time (in terms of days) are in advance before a Change can be implemented.
Key factors are Planned Start Date, Priority and Change Type. Depending on customer requirements and change management process there will be other factors to consider but for now let's focus on how to calculate lead time.
The Formula
Here is an example on how to calculate the Lead Time.
var changePlannedStartDate = "2020-03-29 15:00:00";
var date1 = new GlideDateTime(changePlannedStartDate);
var date2 = new GlideDateTime(gs.nowDateTime());
// ge the difference in terms of number of days elapse between two dates
// returns days in format: ddd hh:mm:ss
var diff = gs.dateDiff(date1.getDisplayValue(), date2.getDisplayValue(), false);
// obtains only number of days
// if diff has a length of 8 characters then it's only hours difference meaning 0 days lead time
var daysDiff = diff.length == 8 ? 0 : parseInt(diff.slice(0,-8));
// make it a positive number
if(daysDiff < 0) daysDiff = -1 * daysDiff;
Now with the Lead Time calculated you may do different things:
- Display a custom message in the Change form to let know the requester that there's no sufficient lead time to continue with the planned schedule.
- You may automatically change the type of the Change; say for example from Normal to Emergency
- Perhaps additional approvals are needed for so short notice.
Oscar Lopez
@oslovanet
- 20,475 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Oscar,
It is good practice to check the lead time depending on the change type to very if the lead time is within limits for the request type. But automatically changing the type of change from Normal to Emergency is not a good idea. Customers I know who requested an automatic change, came back on their decision.
Best regards,
Jan
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This Code is written on the basis of some condition, it has lead time of 3 weeks with Very high risk change and and so on,
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Samartha Shetty - thank you for the code, it is working wonderfully but there is one slight correction, wondering if you can assist.
During testing, I noticed that the newStartDate time is populating in UTC time:
gs.addErrorMessage('Planned Start Date Should be after ' + newStartDate + " for Normal Change With "+r);
Would you know how to get this value to display in local time?
Edit - figured it out - for those that come across this, you can get the local display time to show up by adding the getDisplayValue():
gs.addErrorMessage('Planned Start Date Should be after ' + newStartDate.getDisplayValue() + " for Normal Change With "+r);
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi
You can use getLocalTime() function with the GlideDateTime
ex:
var newStartDate=new GlideDateTime().getLocalTime();
I believe this should work.
Thanks
Samartha C Shetty
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thank you for the solution but when I am testing there is no error message. the time is in UTC only.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi @sayali97
Please check if the code is entering the if statement, If not check if both start and end date is in same tz.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
how are you handling the lead time when rejecting a Normal Change record? Are you having it reset or will it hold the lead time for corrections so the user can keep the same implementation date
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Is there a way to setup a lead time for normal changes for medium and low risk to before a CAB Meeting. I want to prevent changes from being submitted minutes before CAB. I want to set 2 business day lead time before our CAB Meetings.