
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 07:25 PM
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):
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;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 06:06 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 02:48 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 05:57 PM
I got a random user.
[0:00:00.024] Script completed in scope global: script
*** Script: Colin Robinson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 06:06 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 06:40 PM
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'));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 07:02 PM
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