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

Hi Richelle,



The one above goes into a mail script the one you can invoke from your notification.



Thanks,


Berny


In regards the scheduled job, i just need to be a link that invokes the event (the one you should already have defined in your event registry and associated to your notification).



The code will be something like the following:



gs.eventQueue("myeventname", glideRecord, anyParameter1, anyParameter2);



where:


- myeventname corresponds to the name of your event


- glideRecord corresponds to current or an instance of a GlideRecord record that you may want to pass along on the event/notification


- and anyParameter1 and anyParameter2 corresponds to any parameter you will like to pass to your event/notification. Usually these are used for recipients or gs.getUserID() and gs.getUserName().



Thanks,


Berny


I hope this helps!



Thanks,


Berny


Thank you, that's very helpful. Now I just need to build out all of the elements...



Richelle


You're welcome Richelle. Please let me know if you need any further help.



If possible, please mark as helpful the responses so that others can refer to it as something that helped you to reach your solution.



Thanks,


Berny