Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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 Bryant,



Try the below code in background script first (system definition > scripts Background)



var gr = new   GlideRecord("sys_user");


gr.query();


if(gr.next()) {


  gs.info(gr.getValue('name'));


}



Thanks,


Nag.


I got a random user.



[0:00:00.024] Script completed in scope global: script



*** Script: Colin Robinson

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.


There is no include script. I'm running from Notification Email Script. It doesn't have to be be html if that makes things simpler. Maybe my initial coding is wrong? I think I need to be pulling from cmn_rota.group for the on-call user. Maybe something close to this:




var gr = new GlideRecord("cmn_rota");


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



if(gr.next()) {



template.print(gr.getValue('user_name'));



}


Can you tell me how you can get today's current assign person of a group?



I mean what is the field that tells the person in assigned so we can build the query.



Query "'JOINsys_user_group.sys_id=cmn_rota.group!active', '=', 'true'" will just get the group   wiht name "cmn_rota" and active but what about the assigned person.



To build the right query I need to see which field determines the assigned person.



You can give me a screen shot or if possible come to screen sharing meeting i can help u.



Thanks,


Nag