RT Template Howto

Dale Bewley <dale@bewley.net>
23 February 2000


Table of Contents


1. Introduction

This is a brief doc on how to create templates for use in RT.


2. Types of Templates

Templates are located in rt/etc/templates/queues/<queue_name> The templates available for customization are:


3. Embedable Tokens

Templates support the embedding of "tokens" for dynamically inserting information such as the ticket owners contact info.

The available tokens are

3.1. Token Interpolation

The code for interpolating these tokens can be easily hacked and is found in rt/lib/rt/mail.pm. It looks something like this:

    $template =~ s/%rtname%/$rtname/g;
    $template =~ s/%rtversion%/$rtversion/g;
    $template =~ s/%actor%/\'$in_current_user\' ($rt::$users{$in_current_user}{real_name})/g;
    $template =~ s/%owner%/$rt::$users{$rt::req[$in_serial_num]{owner}}{real_name} ($rt::$users{$rt::req[$in_serial_num]{owner}}{email})/g;
    $template =~ s/%subject%/$in_subject/g;
    $template =~ s/%serial_num%/$in_serial_num/g;
    $template =~ s/%mailalias%/$mail_alias/g;
    $template =~ s/%content%/$in_custom_content\n/g;
    $template =~ s/%req:(\w+)%/$rt::req[$in_serial_num]{$1}/g;
    $template =~ s/%trans:(\w+)%/$rt::req[$in_serial_num]{'trans'}[$in_id]{$1}/g;
    $template =~ s/%queue:(\w+)%/$rt::queues{$rt::req[$in_serial_num]{'queue_id'}}{$1}/g;

4. Sample Templates

The default templates are found in rt/lib/generic_templates/ while normal queue templates are stored in rt/etc/templates/queues/<queue_name>/. I find it useful to put the full path name into the templates while you are tweaking them so it is easier for yourself and others to track down. You probably want to remove that from your templates that will go to requestors once you have your templates solidified.

4.1. Sample give Template

Example of template used to notify a user when a request has been given to them. You'll notice that I have included a link of http://rt.domain.com/ to remind the new owner of where to go to work on the ticket. I suppose it would be pretty crafty to include a direct link to the ticket.

Ticket %serial_num% has been given to you by %actor%.
Now it is YOUR job to get this issue resolved! Do it!!

--
%actor%
%mailalias% http://rt.domain.com/
/usr/local/rt/etc/templates/queues/noc/give

4.2. Sample web_create Template

This template automatically populates the textarea field when you create a web based request. In my installation we pretty much exclusively use the web interface and our tickets are only used inside the company.

-=-=-=- For Internal use only - Do not send outside company -=-=-=-

**********************************************************
-- DESCRIPTION -------------------------------------------
**********************************************************


-- APPLICATIONS AFFECTED ---------------------------------


-- CUSTOMER IMPACT ---------------------------------------


-- CONTACT INFORMATION -----------------------------------
%actor%
Network Operations - 317-555-5555 - noc@domain.com


-- UPDATE SECTION -----------------------------------


-=-=-=- For Internal use only - Do not send outside company -=-=-=-

4.3. Sample transaction Template

This template will only be used if you choose to notify queue members of transactions.

%trans:text_time%: Ticket %serial_num% was acted upon.

  Ticket Num: %serial_num%
 Transaction: %trans:text%

       Queue: %req:queue_id%
        Area: %req:area%
     Subject: %req:subject%
       Owner: %req:owner%
  Requestors: %req:requestors%
      Status: %req:status%

-------------------------------------------------------------------------
%trans:content%
-------------------------------------------------------------------------
/usr/local/rt/etc/templates/queues/noc/transaction