Email Notification Report - Changes Overdue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2017 04:22 PM
Hiya,
I am attempting to create a html email notification report, similar to jim.coyne 's example found here: Using Email Notifications as Custom Reports.
My criteria for the report is to send assignee's a list of changes they have assigned to them that are now overdue. The overdue part is referencing against a field called Planned End Date (end_date).
I have created the event and scheduled job, as per the instructions found on Jim's blog post. These are working fine with other html reports I have created.
I have created the mail script, and it works perfectly when I click on preview notification.
Mail Script:
/*
HTML Email Reporting - Changes Overdue
CSS Styling can be found in the Email Script: rc_table_report_css
*/
var gr = new GlideRecord('change_request');
//Report Query
gr.addEncodedQuery("active=true^end_date<javascript:gs.daysAgoStart(0)^state!=1^assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe");
gr.query();
//Start of table
template.print('<table class="report-table">');
//Table header
template.print('<tr class="tr"><th class="th" colspan="4">Overdue Changes Assigned to You</th></tr>');
template.print('<tr class="tr"><th class="th">Number</th><th class="th">State</th><th class="th">Short Description</th><th class="th">Planned End Date</th></tr>');
//Table data
while(gr.next()){
template.print("<tr><td>" + gr.number + "</td><td>" + gr.state.getDisplayValue() + "</td><td>" + gr.short_description + "</td><td>" + gr.end_date + "</td></tr>");
}
//End of table
template.print("</table");
The trouble I am having is getting the notification to send to each person who has an overdue change assigned to them. The below is what I have set on the notification at the present time:
When to send
Send when: Event is fired
Event Name: rc.weekly.reporting.change
Who will receive
Users/Groups in fields: Assigned to
Send to event creator: yes
Event details are below:
Event Name: rc.weekly.reporting.change
Table: Change Request
Fired By: (RC) Weekly Reporting - Change
We currently have 24 changes that meet this query criterion (minus the dynamic assigned to me) in our dev instance, and there are 12 different assignees. the expected behaviour is to send 12 emails to those that have overdue changes assigned to them.
Does anyone have an idea on how I can get this email notification firing?
Thanks in advance,
Brendan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 10:02 AM
So I have a table following screenshot and one of the field have users.....similarly in your case you can make comma separated sys_id of users whom you need to send notifications. like var userList = 'sys_id_user1,sys_id_user2..........' and pass it as any of last two parameters which are considered as Parm 1 and parm 2 respectively. So if you make something like this gs.eventQueue("consumable.notification", reorder, itemArr, String(userList)); then in your notification you have to choose Event Parm 2 contains recepient check box
function notifyForReorder() {
var reorder = new GlideRecord('u_consumable_reorder_notificat');
reorder.query();
while (reorder.next()) {
var items = getAllItemsThatNeedReordering(reorder.u_consumable_type);
var itemArr = '[' + items.toString() + ']';
gs.log('itemArr: ' + itemArr, 'testNotif');
if (itemArr != '[]' && itemArr != '') {
gs.eventQueue("consumable.notification", reorder, itemArr, String(reorder.u_notify));
}
}
}