Daily Ticket "Summary" E-mail
During our helpdesk roll-out, one of the tasks I set out to complete was the creation of a daily ticket reminder to users. Basically, this is a little summary to be sent every day to users and queues (if e-mail addresses were provided) with a count of Open, WIP (work in progress), and re-opened tickets. Here is how I went about creating this e-mail.
- Create a new notification policy: This is found by going to: View -> Tasks -> Incident Resolution -> Incidents -> Helpdesk -> Notification Policies
- Use the following Query:
SELECT hd1.[assigned_to_worker_name] as 'Worker_Name', hd1.[assigned_to_worker_email] as 'Worker_Email', sum(case when hd1.[workitem_status_lookup_id] = '300' then 1 else 0 end) as 'Open_Incidents', sum(case when hd1.[workitem_status_lookup_id] = '450' then 1 else 0 end) as 'ReOpened_Incidents', sum(case when hd1.[workitem_status_lookup_id] = '150' then 1 else 0 end) as 'WIP_Incidents' FROM dbo.HD_workitem_current_view hd1 WHERE hd1.[assigned_to_worker_status] = 'a' GROUP BY hd1.[assigned_to_worker_name], hd1.[assigned_to_worker_email] ORDER BY hd1.[assigned_to_worker_name]
- Create a new Automation Action similar to this:
The above process sends an e-mail based on the schedule we set. For us it is every Mon - Fri at 8:00 am. Here is a breakdown of what the SQL lines above do:
SELECT hd1.[assigned_to_worker_name] as 'Worker_Name', hd1.[assigned_to_worker_email] as 'Worker_Email',
This code simply selects the Worker Name and E-mail address. We select name to help personalize the e-mail. It also helps the workers identify if this e-mail is to their Queue or their Worker Queue.
sum(case when hd1.[workitem_status_lookup_id] = '300' then 1 else 0 end) as 'Open_Incidents', sum(case when hd1.[workitem_status_lookup_id] = '450' then 1 else 0 end) as 'ReOpened_Incidents', sum(case when hd1.[workitem_status_lookup_id] = '150' then 1 else 0 end) as 'WIP_Incidents'
This code basically creates a column with a sum of the values and totals them up for us. In the above case, 300 is our "Open" ID, 450 is our Re-Opened ID, and 150 is our WIP ID. You can customize this as you see fit and increase/remove anything. The syntax is the same as above. Just change the ID value, and the "as" part to something descriptive so you can use it in the e-mail.
FROM dbo.HD_workitem_current_view hd1 WHERE hd1.[assigned_to_worker_status] = 'a'
This code tells the query where to find the data. I did find that I had to add the HD_ to get this to function from the Notification Policy itself. Using Query Analizer I had to remove that little bit for testing. The "Where" piece basically limits the results to any "Active" Worker/Queue. This way if you inactivate a worker or queue, it will no longer try to send e-mails to them. Just more of a clean-up to reduce the e-mail being sent by this system.
I hope this helps someone else who might have a similar request/desire. The e-mail that is sent is pretty short and sweet and is meant for viewing on a handheld device.
- Login or register to post comments
- 1961 reads
- Printer-friendly version

















Very nice!
Honestly, I've wondered how hard it would be to do something like this. I'm glad to see someone has already gotten it working. Will be checking it out just to see how it looks and all, but I'm sure this might be the "kick in the pants" some people need to keep their tickets going.
This is very nice
I just added this and ran a test. I like this.
I'm not a SQL guy by any means, but I was wondering if this could be taken one step further.
Could a condition be set where if all of the values are all 0 that no notification be sent? I figure why send a notification out if there is nothing to work on.
I know I'll try to incorporate other posts into this where I would include a count of the tickets due that day.
How to exclude the people with Zero tickets
I added some tweaks below. In my environment we care more about what's Open and what's on Hold.
(1) added the type_lookup_id in the Select clause to distinguish incidents, requests, and changes
(2) added the HAVING clause after GROUP BY to eliminate any results where workers have no open tickets
SELECT
hd1.[assigned_to_worker_name] as 'Worker_Name',
hd1.[assigned_to_worker_email] as 'Worker_Email',
sum(case when (hd1.[workitem_status_lookup_id] = '300' AND hd1.[workitem_type_lookup_id] = '10') then 1 else 0 end) as 'Open_Incidents',
sum(case when (hd1.[workitem_status_lookup_id] = '300' AND hd1.[workitem_type_lookup_id] = '100') then 1 else 0 end) as 'Open_Requests',
sum(case when (hd1.[workitem_status_lookup_id] = '300' AND hd1.[workitem_type_lookup_id] = '6') then 1 else 0 end) as 'Open_Changes',
sum(case when hd1.[workitem_status_lookup_id] = '500' then 1 else 0 end) as 'Hold_Tickets'
FROM
dbo.HD_workitem_current_view hd1
WHERE
hd1.[assigned_to_worker_status] = 'a'
GROUP BY
hd1.[assigned_to_worker_name], hd1.[assigned_to_worker_email]
HAVING
(sum(case when hd1.[workitem_status_lookup_id] = '300' then 1 else 0 end) + sum(case when hd1.[workitem_status_lookup_id] = '500' then 1 else 0 end)) <> 0
ORDER BY
hd1.[assigned_to_worker_name]
Good addition
Nice addition to this. Haven't spent time looking at how to resolve the issue with 0 tickets.
Nice report to keep folks up to date on their tickets
A slight modification to the original and to ignore the '0' counts for open/Hold/resolved and Planned.
: SELECT hd1.[assigned_to_worker_name] as 'Worker_Name', hd1.[assigned_to_worker_email] as 'Worker_Email', 'Open'= SUM(CASE when hd1.[workitem_status_lookup_value]='Open' Then 1 else 0 END), 'Planned'= SUM(CASE when hd1.[workitem_status_lookup_value]='Planned' Then 1 else 0 END), 'Hold'= SUM(CASE when hd1.[workitem_status_lookup_value]='Hold' Then 1 else 0 END), 'Resolved'= SUM(CASE when hd1.[workitem_status_lookup_value]='Resolved' Then 1 else 0 END) FROM dbo.HD_workitem_current_view hd1 WHERE hd1.[workitem_status_lookup_id] <> 600 GROUP BY hd1.[assigned_to_worker_name], hd1.[assigned_to_worker_email] order by 1NP or Automation rule
Hi.
I was just wondering why you use a automation rule and not a notification policy to do this?
Replies to Comments
johnquinn: That is something I'm actually looking into myself. The above was just tossed in as a stop gap but stopping notifications when there are no new tickets is something we have considered. Current thinking is we want people to get used to having an e-mail from the system every day so they get used to looking for it. A 0 ticket stop of that e-mail would make it inconsistent for groups that don't get tickets much.
Endo: This is a notification policy. The "Automation Action" you saw in the post refers to the Automation action within the notification policy itself.
I hear ya on that dkerr.
I hear ya on that dkerr. It's not a bad idea just to get the folks used to seeing the message itself.
The thing is I know in my case is some of the people who would be getting this message would question why am I getting a notifcation when there is nothing for me to work on.
I guess its the old double-edged sword.
Funny Side Effect
We recently had this process turn out to be a good red flag for us. The situation was this. The Altiris database, for whatever reason, decided it was going to start Deadlocking. As such, processes started to back up. Because of this, our daily notification didn't show up until around Noon. This was a red flag that something was going on as that e-mail is very reliable and consistent. About 30 min after the e-mail arrived, our workers lost the ability to enter the worker page. About 10 min after that, our customers lost the ability to enter tickets through the winuser page. Funny that the daily annoyance actually had people take notice and the delay in the delivery helped point out a bigger issue.
Thanks!
I plugged this into our HD and I really like it. Thank you!