A World without Walls

Sirius Engineering Team

Simple Request Tracker customisations using callbacks

At Sirius we're fans of Request Tracker, which is excellent free software for running a help desk. One reasonably common question on the Request Tracker user's mailing list is "how do I make setting a subject mandatory when creating a ticket?". Another useful modification that we use at Sirius is to force setting a non-zero priority on tickets.

RT is designed to be easily customised, and one way of achieving both of these features is to hook into Request Tracker's BeforeCreate callback. This callback gets called every time the "Create" button is pressed when creating a new ticket. If you haven't provided a callback the ticket is created as normal. If you have provided a callback, the chunk of code is executed, and the ticket creation can be postponed in the event of unacceptable input such as no subject.

Therefore we can force setting a mandatory subject using the following chunk of perl.

<%init>
my $ARGSRef = $ARGS{'ARGSRef'};

if ($$ARGSRef{'id'} eq 'new')
{
if ($$ARGSRef{'Subject'} !~ /^[a-zA-z0-9]+/)
{
my $msg = loc("You must set a subject, and the subject must start with a letter or number");
$RT::Logger->debug($msg);
push @$results, $msg;
$$skip_create = 1;
}

if ($$ARGSRef{'InitialPriority'} !~ /^([1-4]{1}|99)$/)
{
my $msg = loc("Initial priority must be 1, 2, 3 or 4");
$RT::Logger->debug($msg);
push @$results, $msg;
$$skip_create = 1;
}
}
</%init>
<%args>
$skip_create => undef;
$checks_failure => undef;
$results => undef;
</%args>

To install this into your RT installation, create a file containing the callback under:

share/html/Callbacks/Sirius_Callbacks/Ticket/Create.html/BeforeCreate

On Debian with Debian's RT packages, the full path is

/usr/share/request-tracker3.8/html/Callbacks/Sirius_Callbacks/Ticket/Create.html/BeforeCreate

(Naturally you don't have to use the directory "Sirius_Callbacks", it's an arbitrary name and doesn't need any configuration anywhere.)

It's advised to then clear out the Mason cache, and restart Apache. You will need to clear out the Mason cache if you modify the callback, for the changes to take effect.

Some things to note about the above code.

my $ARGSRef = $ARGS{'ARGSRef'};

gives us reference to several perl variables that will provide useful information in the callback, such as the provided subject and priority.

The variable $results is an array containing messages that should be displayed to the user to help them correct their invalid input.

The variable $skip_create is set to 1 (i.e. true) if invalid input is received, and thus RT knows not to not actually go ahead and create the ticket and display the contents of $results, instead.

A useful improvement would be to allow the regular expressions used to validate the subject and priority to be configured in the RT configuration file, if anybody has a solution, we will be glad to publish the results.

The end result, if you haven't provided the required information.

And if you have, the ticket will be created as normal.

beforecreate-rt

P.S. Thanks to Dominic Hargreaves for the comment: "Unless you're actually patching the Debian package, you shouldn't place your callbacks in /usr/share/request-tracker3.8/... but rather in /usr/local/share/request-tracker3.8/... which is there for just that purpose."

Tags: perl, request tracker, rt

RSSSubscribe to this blog

Contact Us

For editorial queries:
Max Cooter max@techworld.com

For website issues:
Email webmaster@techworld.com

For commercial queries
Russell Kearney russell_kearney@idg.co.uk


You must be logged in to post a comment.

Email this to a friend

* indicates mandatory field


Techworld White Papers

Integrating SharePoint with Lotus Notes

Solving interoperability challenges by migrating away from Lotus Notes and Domino® to an all-Microsoft infrastructure is a costly proposition. Find out how to deliver access to all collaboration and messaging resources through a single interface, without the high costs or risks of a migration.

Download Whitepaper

A guide to messaging archiving: Reduce costs, retain memory and ensure you are legally compliant

This white paper discusses the several reasons to implement a messaging archiving system and provide an overview of ten vendors whose offerings are focused squarely on the archiving space.

Download Whitepaper

Effective security with a continuous approach to ISO 27001 Compliance

Learn more about how you can improve security and comply with ISO 27001 by downloading this whitepaper.

Download Whitepaper

Understanding ITIL service portfolio management

This paper examines the various components of the service portfolio, such as the service catalogue. In addition, it discusses technologies available to develop and manage the service portfolio and to leverage the information contained in the catalogue.

Download Whitepaper

Techworld UK - Technology - Business

Mainsoft

Integrating SharePoint with Lotus Notes

Read this whitepaper and learn how to promote collaboration cost-effectively by integrating SharePoint with your existing Lotus messaging platform. The benefits and capabilities of software coexistence are presented, along with the risks and expenses of a migration.

Download white paper
BMC

Seven Ways ITIL Can Help You in an Economic Downturn

Learn more about how ITIL can help your business weather the economic storm, and how it can leave you better positioned for growth when the economy begins to rebound.

Download white paper
LogMeIn

Delivering Value to Your Business with Next Generation Remote Support Solutions

With the ever increasing mobility of today’s workforce, today's CIO needs to ensure their IT departments deliver cost effective solutions that increase helpdesk productivity, maximise user satisfaction and add real value to their business. View this webcast to discover how next generation remote solutions can help achieve these benefits.

Register Today

Site Map

IDG Network