Can we submit Request for approval in change before the lead time

raginiv
Tera Contributor

I have created a change with 3 business days of lead time. The time frame between Change drafted date and Planned started date is 3 days. after 1 day i have submitted the Requested for approval. even though we have given 3 days of lead time system is allowing to submit for approval on 2nd business day. Is this a normal behavior. The risk conditions were defined as shown in screenshots. please help me on this.

raginiv_0-1739514722269.png

raginiv_1-1739517620996.png

 

raginiv_2-1739517665097.png

script for Planned start date and end date validation.

(function executeRule(current, previous /*null when async*/) {
    var plannedStartElem = current.start_date;
    var plannedEndElem = current.end_date;
    var plannedStartGDT = plannedStartElem.getGlideObject();
    var plannedEndGDT = plannedEndElem.getGlideObject();

    if (plannedStartGDT.after(plannedEndGDT)) {
        gs.addErrorMessage(gs.getMessage("{0} must be after {1}", [ plannedEndElem.getLabel(), plannedStartElem.getLabel() ]));
        current.setAbortAction(true);
        return;
    }

    // The method of duration calculation is used instead of a condition (in the condition builder)
    // to ensure we use the same method of comparison between client and server
    var FIFTY_YEARS_MILLIS = 1576800000000; // 1000 * 60 * 60 * 24 * 365 * 50
    var duration = GlideDateTime.subtract(plannedStartGDT, plannedEndGDT).getNumericValue();
    if (duration > FIFTY_YEARS_MILLIS) {
        gs.addErrorMessage(gs.getMessage("{0} cannot be more than 50 years after {1}", [ plannedEndElem.getLabel(), plannedStartElem.getLabel() ]));
        current.setAbortAction(true);
    }
})(current, previous);
1 ACCEPTED SOLUTION

Hi @raginiv 

 

Check this to calculate lead time

 

https://www.servicenow.com/community/itsm-articles/change-management-lead-times/ta-p/2299624

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

View solution in original post

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @raginiv 

 

How are you checking the lead time? If you notice in the risk conditions, it will only increase the risk level but will not prevent the user from submitting the change.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi Sir, Thanks for your response this is the code for lead time , please confirm me if the lead time effects the "Request approval". can we request the approval anytime. Is this OOB or not. 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    //Type appropriate comment here, and begin script below
    if (newValue != '' && g_scratchpad.lead != "Set" && g_form.getValue('type') == "normal") {
        var ga = new GlideAjax('ValidateLeadBusinessDate'); // calling script include
        ga.addParam('sysparm_name', 'ValidatePlannedLead'); // calling function inside script include
        ga.addParam('sysparm_date', newValue);

        ga.getXMLWait();
        var answer = ga.getAnswer();

        if (answer == 'false') {
            //alert('Planned Start Date should be more than 3 Business days from current date.');
            //g_form.setValue('start_date',' ');
            g_form.clearValue("start_date");
            g_form.showFieldMsg('start_date', "Planned start date must be 3 business days from current date.", 'error');
            return;
        }
    }
}

Hi @raginiv 

 

Check this to calculate lead time

 

https://www.servicenow.com/community/itsm-articles/change-management-lead-times/ta-p/2299624

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************