From Request Tracker Wiki
Jump to: navigation, search

RT 3.8

You can use RT sbin/rt-notify-group-admin rt-email-group-admin to create scrip actions to notify groups and or users.

It looks like the above script no longer exists, and instead was replaced by the concept of 'Queue Watchers' at some point. See the Queue Admin page to select watchers.

The script is in RTHOME/sbin (confirmed in 3.8.6 and up to 3.8.8) and can be used to create new actions that can notify an existing Group or a group of Users. Useful when you need to notify a group only when a special condition is met (i.e. send email to users in the group Dispatchers when a new ticket is created).

The 'Queue Watchers' feature is instead useful when you want a Group (or a User) to automatically be CC or AdminCC of each ticket that belongs to the watched queue.

RT 3.6 and older

Above script is part of an extension that has been integrated into RT 3.8. In 3.6 and older versions you can install RT-Action-NotifyGroup from CPAN.

Using custom code in Templates


This Template will email the members of an RT Group. The default template code is for when a new ticket is created, but you can change it to include whatever message you would like.


Original author: Jeff Hoover (jhoov)

The majority of the perl code was taken from the OnCreateAddGroupCc ScripAction.

How To Use

These instructions assume you want to be emailed when a new ticket is created:

  1. Create a new template with the code below, replacing the $GroupName variable with the name of the RT group you want to email.
  2. Create a scrip that uses the template: Description: On Create Notify IT Condition: On Create Action: Notify Other Recipients Template: <your template from step 1> Stage: TransactionCreate

The Template

To: {
   my $GroupName = 'IT';
   # instantiate a group object
   my $addGroupObj = RT::Group->new($RT::SystemUser);
   return undef unless $addGroupObj;
   my $addGroupMembersObj = $addGroupObj->UserMembersObj;
   my $res = '';
   # walk through members of group
   while ( my $userObj = $addGroupMembersObj->Next) {
       my $email = $userObj->EmailAddress;
       next unless $email; # email can be empty
      $res .= ', ' if $res;
      $res .= $email;
 RT-Attach-Message: yes
 A new ticket was created in the {$Ticket->QueueObj->Name} queue.
      Subject: {$Transaction->Subject || $Ticket->Subject || "(No subject given)"}
   Requestors: {$Ticket->RequestorAddresses}
  Ticket <URL: {$RT::WebURL}Ticket/Display.html?id={$Ticket->id} >

NOTE: Don't add any characters before '{' or after '}'.

Or, in RT 4 you can just use this:

To: { my $group = RT::Group->new( $RT::SystemUser ); $group->LoadUserDefinedGroup("group name here"); $group->MemberEmailAddressesAsString; } ...