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

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


Hi Berny,



I have a question....when you created the scheduled job, which option did you use?   We are on Geneva, and below are the options.   Did you just use "run a script of your choosing"?



Thanks,
Maria






find_real_file.png


Hi Maria,



That's right. I used the option: Automatically run a script of your choosing.



I hope this helps .



Thanks,


Berny


Hi Berny,



Will you share the script you used in the Scheduled Job to trigger the notification? The one above is what I put in the Notification itself, right?



thanks,


Richelle