OnStealEnhanced: Difference between revisions

From Request Tracker Wiki
Jump to navigation Jump to search
m (2 revisions imported)
(No difference)

Revision as of 15:15, 6 April 2016

See also

CustomConditionsSnippets for On {Take, Steal, Give, Give Up, Assign, Re-Assign} and other cool things.

Contributed by

Chris Allermann

Overview

This custom condition is based on the OnSteal condition shown in the RT Essentials book, page 87. An additional piece of logic has been put in place to eliminate a bogus stolen ticket notification when one user gives a ticket to another user.

First, setup the template

Name:  Stolen Ticket Notification
Description: Template for stolen ticket notification
Content:

To: {my $user = new RT::User($RT::SystemUser);
$user->Load($Transaction->OldValue); $user->Name || $Transaction->OldValue}
Subject: [{$rtname } #{ $Ticket->Id() }] Stolen: { $Ticket->Subject() }

A ticket you owned:
  { $Ticket->Subject() }

has been taken by { $Ticket->OwnerObj->Name() }.

{ $RT::WebURL }Ticket/Display.html?id={ $Ticket->id }


Second, setup the Scrip

Description: On Stolen Ticket notify old owner
Condition:  User Defined
Action: Notify Other Recipients
Template: Global Template: Stolen Ticket Notification
Stage: Transaction Create
Custom Condition:

return 0 unless $self->TransactionObj->Field eq 'Owner';
return 0 if $self->TransactionObj->OldValue == $self->TransactionObj->Creator;
return 1 if $self->TransactionObj->OldValue != RT::Nobody()->id();
return 0;



Nothing really groundbreaking here. Just eliminating some unnecessary e-mail in my inbox. 2007-06-19: Eliminated a bug in the sample template. Added details for quick implementation by others. 2007-08-23 (Andreas): Most people will want to use "$user->EmailAddress()" (without the quotes) instead of $user->Name in above template.