[rt-users] Tickler program for tickets approaching their due date

Gene LeDuc gleduc at mail.sdsu.edu
Tue Aug 14 16:26:19 EDT 2007


Hi All,

It's time to share some code!

Problem: We wanted ticket owners and adminccs to get daily reminders 
(ticklers) of the tickets they are responsible for when their ticket due 
date gets close.  We didn't want the tickler to be triggered by the age of 
the ticket, just the due date.  This distinction is important to us because 
we often extend the due date of tickets and want the ticklers to stop until 
the new due date approaches.  I found at least one script that sends 
ticklers based on the age of the ticket, but none that used the due date to 
determine whether one should be sent.

To do this I created a custom field called NagDays to determine what 
"close" means with respect to the due date.  This field contains a number 
that represents how close we want to get to the due date before the ticket 
owner and adminccs start getting pinged.  Then I downloaded a script from 
the wiki and slashed it up pretty good until it did what we wanted.  Since 
we don't work on weekends, I also wanted to ignore Saturdays and Sundays, 
so I used Jesse's Business::Hours package from CPAN for the date 
calculations.  Since the Business::Hours package can only count forwards, I 
added a method that lets me count backwards from the due date (the new 
sub_seconds() method is at the end of the code).  We run the script in a 
cron job and all owners and adminccs of tickets that are within NagDays of 
their due date get a daily tickler to gently remind them of what is 
important in life.  Tickets that are overdue get special attention in the 
message.

There are some things that need to be done before this script will do anything.
1.  The custom field NagDays needs to be created and added to each queue 
that you want to be looked at.  This field contains the number of days 
prior to a ticket's due date that ticklers should be sent.  In other words, 
a tickler is sent when a ticket gets within NagDays of its due date.  Note 
that the script doesn't really care about queues, it only looks at tickets 
- but tickets must have a NagDays field in order to be looked at.
2.  Tickets that do not have a due date are ignored, so you should set a 
default value in the queue configuration (ie. "Requests should be due in 5 
days").
3.  You need to assign a value to the NagDays custom field when the ticket 
gets created.  We do this with a custom On Create scrip.  Since we are 
closed on weekends, we also use the same scrip to set a new due date that 
uses business days instead of calendar days.  If you are a 24/7 shop just 
rip the Business::Hours stuff out of this script.

The script logs an "Info" entry to rt.log for each ticket that it sends out 
a tickler for.  The entry lists the ticket number, subject, and the 
addresses that the tickler was sent to (should be the ticket owner and the 
adminccs).

This script also consolidates ticklers across all queues so that each 
person being pinged only gets one tickler message per day.  The tickler 
message contains all applicable tickets for the user and includes the 
following information for each ticket: queue name, ticket number, 
requester, subject, due date, URL, overdue indicator.  You can add whatever 
else you want.

Note - The attached script will not generate any e-mail or log entries 
until you change the $debug value to 0; this is so you can see what it does 
without blasting mailboxes with test messages.  Once you think you like 
what you see, locate the line that says "$debug = 1" and change it to 0.

I hope this is useful to someone.  Feel free to modify it as needed.  If 
you add any Really Cool features I'd like to hear about them.

The usual disclaimers apply: If anything bad happens it's your fault, not 
ours, for trusting a script that you didn't write.

Regards,
Gene



-- 
Gene LeDuc, GSEC
Security Analyst
San Diego State University 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rt-tickler.pl
Type: application/octet-stream
Size: 11141 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20070814/43a51a73/attachment.obj>


More information about the rt-users mailing list