Change Management - Lead Time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2012 11:36 AM
Does anyone know if there is any type of Business Rule or Script that can be done or something to configure it automatically from the "Creation Date" of a change to the Planned Start date?? We require a 10 day Lead time for our application changes but we report off of all of them. Right how our Change coordinator manipulates the Cab report and adds a "Lead TIme" in the report once it's exported to figure out the Lead time..
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2012 12:28 PM
For our changes; we have a 3, 5 and 10 day lead time from the date proposed. So, this is the script I made to force the user to select a date that is in the correct range. It also checks to see if the days in the lead range are weekends, if so it adds one day per weekend day it finds. Our time formats are a little weird, so you can ignore the part of the script that converts time. You can also modify it so it automatically populates your planned start date.
// The following script is used to control the date ranges that are selectable based on criteria selected by the user on the change form.
// The script validates the Risk, Type and Start Date fields.
// Risk: Determines which days are not selectable. The condition is always one day less the expected duration as the current day is counted in the expected condition.
// Type: Determines whether or not dates should be restricted. (Emergency and Standard) are to be excluded from restrictions.
// Start Date: This value is compared against the current and selected dates
// This script has three date variables. One is used to calculate the lead date (selectable dates)
// The next date variable gets the current date and saves it for comparing weekend days
// Function: check_for_weekend_days checks for the number of weekend days in the ragne
// Function: convert_date_time converts the date and time from standard javascript format into our preferred format
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (!isLoading) {
var risk = g_form.getValue('risk');
var type = g_form.getValue('type');
var start_date = g_form.getValue('start_date');
g_form.setValue("end_date",""); // clear end_date for validation
var risk_lead_time_days = 0; // Used to calculate lead time
var lead_date =new Date(); // Date for Change to start (risk_lead_time_days + weekend_offset_count)
var weekend_check =new Date(); // Check for weekends
if (risk == "1") { risk_lead_time_days = 2; risk_type = "Low";} // Risk Low = 3 days lead time
if (risk == "2") { risk_lead_time_days = 4; risk_type = "Medium";} // Risk Medium = 5 days lead time
if (risk == "3") { risk_lead_time_days = 9; risk_type = "High";} // Risk High = 10 days lead time
if ((type != "Emergency") && (type != "Standard") && (type != "Urgent")) {
lead_date.setDate(lead_date.getDate()+risk_lead_time_days); // Create base lead time
check_for_weekend_days(weekend_check,lead_date); // Check for weekends
var new_lead_date = convert_date_time(lead_date); // Convert date/time format
var strip_time_new_lead_date = new_lead_date.slice(0,8); // Checking by date; not by time
var strip_time_newValue = newValue.slice(0,8); // Checking by date, not by time.
if ((strip_time_newValue < strip_time_new_lead_date) && (start_date != "")) { // Check if selected (newValue) is on or after lead time
var prompt_lead_date = risk_lead_time_days +1;
alert("Notification:\n\nChange Requests with a \[" + risk_type + " Level Risk\] require \[" + prompt_lead_date + "\] Business Days planned lead time.\n\nThe current selected date is:\n" + newValue + "\n\nThe minimum lead time should be on or after:\n" + strip_time_new_lead_date + "\n\nPlease try again.");
g_form.setValue("start_date","");
g_form.setValue("end_date",""); // clear end_date for validation
}
}
}
}
function check_for_weekend_days(start_date,end_date) {
// Check for weekend days
while (start_date <= end_date) { // Check date range for weekend days
if ((start_date.getDay() == 6) || (start_date.getDay() == 0)) {
end_date.setDate(end_date.getDate()+1);
}
start_date.setDate(start_date.getDate()+1);
}
}
function convert_date_time(date_time) {
// Format Date & Time
var convert_month = ("0" + (date_time.getMonth() +1)).slice(-2);
var convert_date = ("0" + date_time.getDate()).slice(-2);
var convert_year = ((date_time.getFullYear()).toString()).slice(-2);
var convert_hour = date_time.getHours();
var convert_meridiem = "";
// Set to 12 hour clock
if (convert_hour == 0) { convert_hour = 12; convert_meridiem = "AM"; }
if (convert_hour <= 11) { convert_meridiem = "AM"; }
if (convert_hour >= 13){ convert_hour = (convert_hour-12); convert_meridiem = "PM"; }
if (convert_hour == 12 && convert_meridiem != "AM"){ convert_meridiem = "PM"; }
convert_hour = ("0" + convert_hour).slice(-2);
var convert_minutes = ("0" + date_time.getMinutes()).slice(-2);
var convert_seconds = ("0" + date_time.getSeconds()).slice(-2);
var formatted_date_time = convert_month + "-" + convert_date + "-" + convert_year + " " + convert_hour + ":" + convert_minutes + ":" + convert_seconds + " " + convert_meridiem;
return formatted_date_time;
}
/* No longer used
function check_for_weekend_days(start_date,end_date) {
// Check for weekend days
var weekend_count = 0; // Clear counter
//if (end_date.getDay() == 6) { weekend_count++; } //hack if end-date ends on saturday
while (start_date <= end_date) { // Check date range for weekend days
if ((start_date.getDay() == 6) || (start_date.getDay() == 0)) {
weekend_count++;
}
start_date.setDate(start_date.getDate()+1);
}
return weekend_count;
}*/