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?
         

  

5 REPLIES 5

Hi, Abi. I have the exact same need. It's not enough for the "Conflicts Detected" List in the "Conflicts" tab of a Change request to tell me the name of the cmn_schedule record, I need it to display the name of the exact "cmn_schedule_span" (Schedule Entry) that it's truly conflicting with. I really can't believe ServiceNow OOB doesn't do this.

And if there's no solution for the  "Conflicts Detected" list , I'd at least like to be to create a report to get them directly so I may share it with Change owners so they know exactly which span they're conflicting with.

 

Did you ever figure out a solution??  Thank you!

Scott