On-Call Email Notification

Beto
Mega Guru

I am trying to send out an on-call email notification of our managers. How can I exclude the everything but today's current assign person of a group? My script show's tomorrow date for some reason. I need some guidance.

My desired output:

Manager On-Call Primary John Smith 7/20/2017

Current Output (looks messy):

find_real_file.png

My 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.today());

              var html = fsr.getReport();

              return html;

      }

1 ACCEPTED SOLUTION

Hi Bryant,



The above code is just to tell how can you get the user name alone.



If you want the complete solution please paste the complete code



I think there will be a script include "FormattedScheduleReport()" which you are using to build the HTML. Paste that code also so I can have a look.



Thanks,


Nag.


View solution in original post

13 REPLIES 13

sbrnag
Mega Expert

Hi Baker,



Some methods use the Java Virtual Machine time zone when retrieving or modifying a date and time value. Using these methods may result in unexpected behavior. Use equivalent local time and UTC methods whenever possible.



Try to user GlideDateTime API to work with dates.



Thanks,


Nag.


Beto
Mega Guru

Does anyone know how I can pull just John Smith? I only want the name of the current scheduled person.


var gr = new GlideRecord("sys_user");


What ever querry u want



if(gr.next()) {



var username = gr.getValue('user_name');



}



Thanks,


NAg.


I am getting a null now. What am I missing?




var emailBody = onCallSchedule();


        template.print(emailBody);


       


      function onCallSchedule(){


              var groups = [];


              var gr = new GlideRecord("sys_user");


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


              gr.addOrderBy('name');


              gr.query();


              if(gr.next()) {



var username = gr.getValue('user_name');



}


      }