Weekly Notification with a formatted On-Call Schedule report for all support groups

bernyalvarado
Mega Sage

Hi all,

I'm looking to develop a weekly notification for all the on call support groups using the same format as the formatted on-call schedule report. Unfortunately, we have a large number of groups and schedules and running the on-call formatted schedule report for all groups will timeout.

Any good ideas of how to accomplish this "formatted on call report" without any risk of a timeout regardless of the amount of on call schedules or assignment groups?

Thanks,

Berny

1 ACCEPTED SOLUTION

bernyalvarado
Mega Sage

I was able to do this. In case it's helpful for anybody else, here's how i did it...



a) Created a schedule job that will be in charge of invoking an event that will trigger a notification


b) Within the notification I have a mail script that will pull all the assignment groups and will generate the html leveraging the same functions that the system uses to generate the scheduled report.



Here goes the code of the mail script:



var emailBody = onCallSchedule();


template.print(emailBody);



function onCallSchedule(){


      var groups = [];


      var gr = new GlideRecord('sys_user_group');


      gr.addQuery('JOINsys_user_group.sys_id=cmn_rota.group!active', '=', 'true');


      gr.addOrderBy('name');


      gr.query();


      while (gr.next()) {


              groups.push(gr.sys_id.toString());


      }


 


      var fsr = new FormattedScheduleReport();


      fsr.buildSchedule(groups.join(','), gs.beginningOfThisWeek(), gs.endOfThisWeek());


      var html = fsr.getReport();


      return html;


}



Thanks,


Berny


View solution in original post

19 REPLIES 19

I followed the same thing. When I loook at event log. It shows event triggered. But notifications isn't sent


Hello Richelle,

 

The data is populating as expected however it is coming as a table view, would like to have it in Formatted format, could you please help me with this.

rogerburns
Tera Expert

Hi Berny, et al,


This is a great post, and helpful to new customers (like me).   It's worth noting that the On-Call data comes from multiple, and sometimes virtual, tables, which was why we were unable to configure a simple report to answer the simple question of "who is on call?"



When we implement this code in our Dev instance, the results are an emailed html document, but there is no more formatting like with the built-in On-Call Schedule -> Schedule Report.   I'm wondering if you solved this issue, and I'm just unfamiliar with programming.



Also, unlike the built-in report, we have an anomaly with the shift data that has a 00:00:00 - 04:00:00, and then 04:00:00 - 09:00:00 section.   In the scheduled report, it shows correctly as 00:00:00 - 09:00:00.   Any suggestions on where to look at this?



Thanks very much for putting this out there.   It's a great resource!


roger


joaof
Mega Expert

I had a similar requirement as this one, however I needed to send the notification as a PDF (similar to the table option found on On-Call Scheduling > Schedule Report).

First, create a new script Scheduled Job and name it something like "Prepare On-Call Schedule Report".
On my script, start date will be always current month's 27th day and end date two months later but on the 1st day.
Sys ID you can see below is the Group Sys ID:

//Set start and end dates
var start = new GlideDate();
var dif_s = 27 - start.getDayOfMonthNoTZ();
start.addDays(dif_s);
start = start.getDisplayValue();

var end = new GlideDate();
end.addMonths(2);
var dif_e = 1 - end.getDayOfMonthNoTZ();
end.addDays(dif_e);
end = end.getDisplayValue();

//Set v_rotation
new OCRotation().vRotationHandling(start, end, '59043c3ddb9a83403af3d3ca4b961967');

Second step is to create a report, I call it "On-Call Schedule Report" that gets v_rotation table and type is list.

Third and last step is to create another Scheduled Job, I call it "Send On-Call Schedule Report". This time it will be a Notification/Report one, set it to run 10-30 minutes after the one created on first step. Select the Report created on second step, select the type of the file, PDF on my case and that it.

Hi Everyone,

 How does the second step works after creating a report.  v_rotation table is returns empty values.

Are we missing a link between step 1 and 2.

new OCRotation().vRotationHandling(start, end, '59043c3ddb9a83403af3d3ca4b961967');