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-21-2017 04:29 PM
so you want to send this email to only the 12 assignee who have overdue changes ? why not you make a list of these users and send it as parm in eventqueue ?
3.1 eventQueue(String, Object, String, String, String)
Queues an event for the event manager.
3.1.1 Input Fields
Parameters:
- Name of the event being queued.
- A GlideRecord object, such as "current".
- An optional parameter, saved with the instance if specified.
- A second optional parameter, saved with the instance if specified.
- An event queue to add the event to.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2017 04:33 PM
Hi Rajeev,
Thanks so much for the speedy response.
These reports will not be static, for example - the changes overdue and assignees will never be the same. For example, next week there could be 20 assignees that will be getting these emails.
Can that still be done in the event param?
Cheers,
Brendan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2017 04:45 PM
Yes. So based on your scheduled job the assignees can be changed. So suppose today your scheduled job will find 2 assignees then pass these two as paramatere in event parm.....tomorrow when this schedule job will run it can find 5 assignees whom this report need to be send then you can pass five assignees as parameter......Your notification will have the check box then send email to event parm1 or 2 based on your script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2017 05:02 PM
Hi Rajeev,
Thanks for your help so far
I have the following scheduled job script:
(function(){
gs.eventQueue("rc.weekly.reporting.change", null, null, null);
})();
However, I am not quite sure the best way to target the users? should the query go into one of the null spots?