Enhanced Ticket Summary Email
I got some of the code and the idea from dkerr and his Daily Ticket "Summary" E-mail, but I felt like more could be done with it and so I spent quite some time customizing it more.
Here is what the emails look like.
I was pretty excited when I found out that HTML can be entered into the email notification action. It just makes the email look quite a bit nicer, and I believe it should be viewable on a handheld device.
Following is the SQL query that goes in a notification policy:
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_Work_Requests', sum(case when hd1.[workitem_status_lookup_id] = '500' then 1 else 0 end) as 'On_Hold_Work_Requests', sum(case when hd1.[workitem_status_lookup_id] = '100' then 1 else 0 end) as 'Planned_Work_Items', sum(case when hd1.[workitem_status_lookup_id] = '600' and datediff(d, hd1.[workitem_modified_on], getdate()) = 0 then 1 else 0 end) as 'Items_Closed_Today', sum(case when hd1.[workitem_status_lookup_id] = '600' and datediff(d, hd1.[workitem_modified_on], getdate()) <= 7 then 1 else 0 end) as 'Items_Closed_This_Week', sum(case when hd1.[workitem_priority_lookup_id] = '100' and hd1.[workitem_status_lookup_id] !='600' then 1 else 0 end) as 'ASAP_Priority', sum(case when hd1.[workitem_priority_lookup_id] = '200' and hd1.[workitem_status_lookup_id] !='600' then 1 else 0 end) as 'High_Priority', sum(case when hd1.[workitem_priority_lookup_id] = '300' and hd1.[workitem_status_lookup_id] !='600' then 1 else 0 end) as 'Medium_Priority', sum(case when hd1.[workitem_priority_lookup_id] = '400' and hd1.[workitem_status_lookup_id] !='600' then 1 else 0 end) as 'Low_Priority', sum(case when hd1.[workitem_priority_lookup_id] = '500' and hd1.[workitem_status_lookup_id] !='600' then 1 else 0 end) as 'Planned_Priority' 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]
I'm gonna break this code out a bit so that everyone will be able to understand what is going on here.
hd1.[assigned_to_worker_name] as 'Worker_Name', hd1.[assigned_to_worker_email] as 'Worker_Email',
This is declaring the variables Worker_Name and Worker_Email to be associated to the database field assigned_to_worker_name and assigned_to_worker_email respectively.
sum(case when hd1.[workitem_status_lookup_id] = '300' then 1 else 0 end) as 'Open_Work_Requests', sum(case when hd1.[workitem_status_lookup_id] = '500' then 1 else 0 end) as 'On_Hold_Work_Requests', sum(case when hd1.[workitem_status_lookup_id] = '100' then 1 else 0 end) as 'Planned_Work_Items',
This portion of code is saying that when the database field, workitem_status_lookup_id, equals "300" then the field is output as "1". If it doesn't equal "300" then it is a "0". Then it calls this query open_work_requests. The other two are the same thing except they deal with on hold and planned work items.
You will probably want to customize this part to your own needs. Not everyone uses planned work item, so exchange that for something else, like resolved incidents (default id "400"), or add whatever status fields you want. We set up one for equipment loans and I may just add that to this query so that we remember when equipment is loaned out.
sum(case when hd1.[workitem_status_lookup_id] = '600' and datediff(d, hd1.[workitem_modified_on], getdate()) = 0 then 1 else 0 end) as 'Items_Closed_Today', sum(case when hd1.[workitem_status_lookup_id] = '600' and datediff(d, hd1.[workitem_modified_on], getdate()) <= 7 then 1 else 0 end) as 'Items_Closed_This_Week',
I find knowing how many tickets have been closed by me today and in the last 7 days to be very interesting and motivating which is why I added this code. What it is doing is looking for closed items, id of "600", and then checking the modified on date against today's date.
The second one does the same thing except it looks for items that have been closed in the last seven days.
Sadly there isn't a database field for the date a incident is closed, so this number may not always be accurate if you make the habit of modifying already closed tickets.
sum(case when hd1.[workitem_priority_lookup_id] = '100' and hd1.[workitem_status_lookup_id] !='600' then 1 else 0 end) as 'ASAP_Priority', sum(case when hd1.[workitem_priority_lookup_id] = '200' and hd1.[workitem_status_lookup_id] !='600' then 1 else 0 end) as 'High_Priority', sum(case when hd1.[workitem_priority_lookup_id] = '300' and hd1.[workitem_status_lookup_id] !='600' then 1 else 0 end) as 'Medium_Priority', sum(case when hd1.[workitem_priority_lookup_id] = '400' and hd1.[workitem_status_lookup_id] !='600' then 1 else 0 end) as 'Low_Priority', sum(case when hd1.[workitem_priority_lookup_id] = '500' and hd1.[workitem_status_lookup_id] !='600' then 1 else 0 end) as 'Planned_Priority'
These queries are pretty simple. First they check the priority of a incident then they check to make sure the incident isn't closed, !=600. Finally they return a true or false, 1 and 0.
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]
The last part is pretty self explanatory.
FROM is what datebase view the query is pulling from.
WHERE is checking making a rule that the work must be active, 'a'.
GROUP BY is just that, it is grouping by the assigned to worker's name and email address.
ORDER By then sorts by the worker's name.
Next we need to configure the email notification action that looks like this:
Here is the code for the message portion, just change the "{}" to "<>":
Worker Name: %DS:Worker_Name%
{span style="color:red"}
Open Tickets: %DS:Open_Work_Requests%
{/span}
On Hold Tickets: %DS:On_Hold_Work_Requests%
Planned Work Items: %DS:Planned_Work_Items%
Tickets Closed Today: %DS:Items_Closed_Today%
Tickets Closed in the Last 7 Days: %DS:Items_Closed_This_Week%
{b}Tickets by Priority:{/b}
ASAP: %DS:ASAP_Priority%
High Priority: %DS:High_Priority%
Medium Priority: %DS:Medium_Priority%
Low Priority: %DS:Low_Priority%
Planned Priority: %DS:Planned_Priority%
Thats about it, please let me know of any improvements, criticisms etc...
And thanks again to dkerr for his great idea.
- Login or register to post comments
- 3003 reads
- Printer-friendly version


















just fantastic Xenon :-)
just fantastic Xenon :-)
Use with multiple queues in the helpdesk dashboard.
First off, this is a great tool for reminding our IT staff about work that needs to be done; however, in our environment, we are using the "show additonal information on the helpdesk dashboard" article. If you have multiple queues displayed to a user, every queue displayed actually sends its own email to the user. So if I have a user assigned to a queue, but have an additional 4 queues visible, it sends them 5 separate emails. I know our IT staff, and they'll just make a rule to send all of these to a folder that never gets checked. Is there a way to reduce these to a single daily email but still list multiple workers/queues?
"They must find it difficult... Those who have taken authority as the truth, rather than truth as the authority."
How would I use this to query and return a summary of all worker
I want the email generated to given me a summary of all my workers incident stats combined together, so that I may guage overall effectiveness of my entire team, or break it down by individual queues as well. For instance one combined set of numbers for desktop, network team, etc.
Summary of all Workers
I've been trying this as well for some time but haven't figured out how to do it either. It may be harder than expected since Altiris HD doesn't have any databases or fields in database associating a worker as the lead/manager of a queue. You can't say 'let me see my team' because there isn't anything saying/documenting you are the lead/manager for that team. Below are the only ways I have been able to create something like this for manangement
For workers query:
You could compile a list of workers that you want and a report can be made, and a task setup to email the report, to show you activity of those specific workers.
For queues query:
A report could be created, and a task setup to email the report, to show you the activity for all or individual queues.
Please let me know if you'd like any more detail about what I've described
Hmm, you pose a real
Hmm, you pose a real difficult one there.
The problem I run across is that it is grouping the fields by worker. Which is good I suppose, but I haven't figured out how to group them in such a way as to email multiple queues or worker reports in one email. I could tell you how to send all the emails to one person. But in my testing of this I didn't come across a simple way to do what you are asking. As far as I can tell you would have to a rather complex SQL code that makes a separate field for each queue or worker.
However, I'm not really a SQL expert, so just because I can't figure out a way to do it doesn't mean it can't be done... I'll play around with it some more, because it is a "feature" that would be nice to have.