We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Report of groups which do not have On-Call Schedules filled out for the next 10 days.

VijayshankaK
Tera Expert

Hi All,

 

Can you please hep me with Report of groups which do not have On-Call Schedules filled out for the next 10 days.

 

I tried using on call schedule table  but no luck 

 

@itil #Reporting

1 ACCEPTED SOLUTION

pavani_paluri
Kilo Sage

Hi @VijayshankaK ,

 

This can’t be done directly via simple reporting on the On-Call Schedule tables, because you’re asking for something that does not exist (i.e., no schedules), which typical filters can't catch.

Instead, you’ll need to do this with a scripted report, scripted REST API, or background script to query:

All groups (sys_user_group)

All On-Call schedules (cmn_schedule_span, on_call_rotation, on_call_roster)

For each group, check if there’s any on-call coverage in the next 10 days

List the groups that have no coverage

var daysAhead = 10;
var endDate = new GlideDateTime();
endDate.addDaysLocalTime(daysAhead);

You can convert this to a script include and call in report with sys_id is one of and then give script include name
var groupGR = new GlideRecord('sys_user_group');
groupGR.query();

gs.print('Groups with NO on-call coverage for the next ' + daysAhead + ' days:\n');

while (groupGR.next()) {
var hasCoverage = false;

// Check for any on-call schedules tied to this group
var onCallGR = new GlideRecord('on_call_schedule');
onCallGR.addQuery('group', groupGR.sys_id);
onCallGR.query();

while (onCallGR.next()) {
// For each schedule, check if any span (roster) covers the next 10 days
var spanGR = new GlideRecord('cmn_schedule_span');
spanGR.addQuery('schedule', onCallGR.schedule.sys_id);
spanGR.addQuery('ends', '>=', gs.nowDateTime()); // Only future spans
spanGR.addQuery('starts', '<=', endDate); // Spans within next X days
spanGR.query();

if (spanGR.hasNext()) {
hasCoverage = true;
break;
}
}

if (!hasCoverage) {
gs.print('- ' + groupGR.name);
}
}

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P

View solution in original post

6 REPLIES 6

Hi Vijay,

I’m looking for the same information. Did this solution work for you?

Hi @ShivalikaM , you can try on callscheduling->Reports->  Schedule Report option which is available OOB .