Customizing Service Desk ticket content sent by mail
Hi,
don't know if this has already been posted or asked but I would like to customize the emails that are sent by the service desk. I have found the page in the configure part where you can edit the text but I am not exactly sure what to put in.
What I am trying to achieve is instead of simply having :
Ticket Updated.
For complete details, see:
http://k1000/userui/ticket?ID=159
I would like to insert the update in the email. I can't tell people to go in the service desk to check the updates. Of course they can if they want to but it would be much better to have the update sent by mail. Can this be easily done ?
I would then also do the same for the ticket closure. Insert the last comment added in the ticket sent inside the closure ticket.
Cheers
Seb
Answers (4)
Thanks for your quick answers.
I have seen those variable and found another post also where it is said to use $ticket_history but this comes with the entire ticket history.
I have tried the $change_desc also but this doesn't seem to work. this is written in the mail.
is there a way to limit the $ticket_history to the last comment added ? That would be what I am looking for.
Cheers
Comments:
-
You would have to use a custom ticket rule to do that. I can post an example if necessary. - chucksteel 11 years ago
-
would really appreciate ;) And if you can let me know how to implement it also would be great.
Thanks for the quick replies ;) - spujado 11 years ago
Here's an example custom rule that emails owners on ticket changes. I would highly recommend that you either read the section in the Service Desk administrators guide that speaks to creating custom ticket rules or check the Kace Kontinuing Education series for videos on the topic.
Here's a blog post that walks you through adding a custom ticket rule to notify the submitter on a new ticket:
http://www.itninja.com/blog/view/ticket-rule-notify-on-new-ticket
For a rule that is triggered for ticket changes, I have the following select statement:
select HD_TICKET.ID, HD_TICKET.ID as TICKNUM, HD_TICKET.TITLE, U1.USER_NAME as OWNER_NAME, U3.USER_NAME as LASTINPUTNAME, DATE_FORMAT(HD_TICKET.CREATED,'%b %d %Y %I:%i:%s %p') as CREATED, DATE_FORMAT(HD_TICKET.MODIFIED,'%b %d %Y %I:%i:%s %p') as MODIFIED, HD_STATUS.NAME AS STATUS_NAME, HD_STATUS.ORDINAL as STATUS_ORDINAL, STATE, U1.FULL_NAME as OWNER_FULLNAME, U1.EMAIL as OWNER_EMAIL, U2.USER_NAME as SUBMITTER_NAME, U2.FULL_NAME as SUBMITTER_FULLNAME, U2.EMAIL as SUBMITTER_EMAIL, U3.EMAIL as UPDATEREMAIL, U3.FULL_NAME as UPDATERNAME, U4.FULL_NAME as INITIALNAME, UNIX_TIMESTAMP(HD_TICKET_CHANGE.TIMESTAMP), HD_TICKET_CHANGE.COMMENT, HD_TICKET_CHANGE.DESCRIPTION as CHANGE_DESCRIPTION, INITIAL_CHANGE.COMMENT as INITIAL_COMMENT, HD_CATEGORY.CC_LIST AS NEWTICKETEMAIL, HD_CATEGORY.NAME AS CATEGORY_NAME, U2.LOCATION AS SUBMITTER_LOCATION, U2.WORK_PHONE AS SUBMITTER_WORK_PHONE, HD_PRIORITY.NAME AS TICKET_PRIORITY, HD_QUEUE.NAME AS QUEUE_NAME from ( HD_TICKET, HD_PRIORITY, HD_STATUS, HD_IMPACT, HD_CATEGORY) JOIN HD_TICKET_CHANGE ON HD_TICKET_CHANGE.HD_TICKET_ID = HD_TICKET.ID and HD_TICKET_CHANGE.ID=<CHANGE_ID> JOIN HD_TICKET_CHANGE INITIAL_CHANGE ON INITIAL_CHANGE.HD_TICKET_ID = HD_TICKET.ID and INITIAL_CHANGE.ID=(select MIN(ID) from HD_TICKET_CHANGE where HD_TICKET_CHANGE.HD_TICKET_ID = HD_TICKET.ID) left join USER U1 on U1.ID = HD_TICKET.OWNER_ID left join USER U2 on U2.ID = HD_TICKET.SUBMITTER_ID left join USER U3 on U3.ID = HD_TICKET_CHANGE.USER_ID left join USER U4 on U4.ID = INITIAL_CHANGE.USER_ID left join HD_QUEUE on HD_QUEUE.ID = HD_TICKET.HD_QUEUE_ID where HD_PRIORITY.ID = HD_PRIORITY_ID and HD_STATUS.ID = HD_STATUS_ID and HD_IMPACT.ID = HD_IMPACT_ID and HD_CATEGORY.ID = HD_CATEGORY_ID and HD_TICKET.OWNER_ID != HD_TICKET_CHANGE.USER_ID and (HD_TICKET_CHANGE.DESCRIPTION not like "%Ticket Created%" or HD_TICKET_CHANGE.DESCRIPTION not like "%Changed ticket Machine from%") and HD_TICKET.HD_QUEUE_ID = 2 and HD_STATUS.STATE != 'closed'
Be sure to change the HD_TICKET_QUEUE_ID = 2 to match the queue ID of your service desk. For this rule the most recent comment is available in the email as $comment.
Comments:
-
Many thanks for this. That should do the trick ;) - spujado 11 years ago
-
Can I ask how $comment works? It's not defined in the query with a "-- $comments" anywhere. I'm trying to add the submitters name and the tech name to the ticket in the email, but nothing is working for me. I'm so confused on getting data from the query to the email.
Thanks,
Joey - joeym304 11 years ago-
Anything selected in the SQL query is available as a variable in the email, so HD_TICKET_CHANGE.COMMENT becomes $comment. Some people add notes to their queries (like -- $comment) to make it more obvious but that isn't required. For the above query the following lines would create the variables for the submitters name:
U2.USER_NAME as SUBMITTER_NAME,
U2.FULL_NAME as SUBMITTER_FULLNAME,
The variables would be $submitter_name and $submitter_fullname.
U1.FULL_NAME as OWNER_FULLNAME, becomes $owner_fullname for the ticket owner and U3.FULL_NAME as UPDATERNAME, becomes $updatername as the technician the updated the ticket. - chucksteel 11 years ago
-
That did the trick and makes a lot sense now that you say it! One last question, can you add history of the ticket instead of the last comment? - joeym304 11 years ago
-
The select statement here includes some syntax that should give a fuller ticket history:
http://www.itninja.com/question/trying-to-send-an-email-on-a-comment-in-a-ticket-not-working
The pertinent select bits are:
GROUP_CONCAT(CONCAT('----- Change by ', UPDATER.EMAIL,' at ',H.TIMESTAMP,' -----\n',
H.DESCRIPTION,'\n',H.COMMENT,'\n\nPlease see your ticket at https://aerocare.panasonic.aero/userui/ticket.php?ID=',H.HD_TICKET_ID,'\n')
ORDER BY H.ID DESC SEPARATOR '\n') HISTORY, -- $history
along with the join statement:
/* complete history*/ JOIN HD_TICKET_CHANGE H ON H.HD_TICKET_ID = HD_TICKET.ID
and then adding the group_by statement:
GROUP BY HD_TICKET.ID
I haven't personally added the full history like this to any of my rules so I don't know how well it works. - chucksteel 11 years ago
-
Not too well, but I think i have enough to go by to get something going! Thanks for all your help! - joeym304 11 years ago