How to get the exact schedule entry record which cause conflict to change request schedule?

abhi710
Tera Contributor

Hi,
There is requirement to get the schedule entry record, which cause conflict to schedule on change request. For this, tried creating BR on conflict table whenever any conflict is created/updated due to change request schedule, to get the overlap schedule record but it fails to get the right record due to some datetime comparison failure.
After BR: Conflict table 

 var sysId = current.change;
    var gr = new GlideRecord("change_request");
    gr.addQuery("sys_id", current.change);
    gr.query();
    if (gr.next()) {
        var schedule = current.schedule.toString();  // Blackout Schedule
        var startDate = gr.start_date;
        var endDate = gr.end_date
        var found = 0;
        var spanGr = new GlideRecord("cmn_schedule_span");
        spanGr.addQuery('schedule', schedule);
        spanGr.addQuery('schedule.sys_class_name', 'cmn_schedule_blackout');
        // spanGr.addQuery('u_blackout_start_time', '<=', endDate);
        //  spanGr.addQuery('u_blackout_end_time', '>=', startDate);
        spanGr.query();
        while (spanGr.next()) {
            var blackoutStart = spanGr.getValue('u_blackout_start_time');
            var blackoutEnd = spanGr.getValue('u_blackout_end_time');

            //check overlap
            if (blackoutStart <= endDate && blackoutEnd >= startDate) {

                found++;
                gs.info("Conflict Schedule name: " + spanGr.getValue("name"));
            } else {
                gs.info("No overlap")
            }
        }
}

Even tried using new GlideDateTime(blackoutStart), GlideDateTime(start).......But still shows no overlap but in change request we can see the conflict record on inside blackout window..... How to rectify this issue and find the exact schedule entry record which conflicts which change request schedule?
         

  

4 REPLIES 4

SumanthDosapati
Mega Sage
Mega Sage

Conflict Calendar might help you answer your question.

 

Regards,
Sumanth

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @abhi710 

What is the use case for this?

You can easily configure the Conflict tab to see which changes or windows are conflicting with your change.
Just review the details there to identify and resolve the issue.

*************************************************************************************************************
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 @Dr Atul G- LNG ,
I need to get the exact schedule entry record(cmn_schedule_span) from the schedule(cmn_schedule - highlighted on image) which is creating a conflict for the planned start and end date of change request. Need to add that particular schedule entry record on conflict related list under conflict tab in change request which had cause conflict. How to get that exact schedule entry record which is causing conflict to change request?
Thanks
Abi

Hi @abhi710 

 

Here’s a fundamental overview of Conflict Detection in ServiceNow:

As per out-of-the-box (OOTB) behavior, a change will be marked as conflicting with another change if:

  • The planned start or end date overlaps with another change.

  • The same CI (Configuration Item) is involved.

  • The dates fall within the blackout window or outside the maintenance window.

In the screenshot you shared, it indicates that the change is in conflict with the defined maintenance or blackout window.

*************************************************************************************************************
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]

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