[Rt-devel] Question about user defined condition

lwang lwang at clusterfs.com
Thu Nov 17 05:10:57 EST 2005


Hi there,

I have put the following piece of code in 
/opt/rt3/local/lib/RT/Condition/OnDelete.pm

package RT::Condition::OnDelete;
require RT::Condition::Generic;

use strict;
use vars qw/@ISA/;
@ISA = qw(RT::Condition::Generic);

sub IsApplicable {
         my $self = shift;
         return ($self->TicketObj->status eq 'deleted');
}

1;

And then enabled it by the following code:
#!/usr/bin/perl

use strict;
use lib "/opt/rt3/lib/";

use RT;
use RT::Interface::CLI qw( CleanEnv GetCurrentUser );
use RT::ScripCondition;

CleanEnv();
RT::LoadConfig();
RT::Init();

my $user = GetCurrentUser();
unless( $user->Id ) {
         print "No RT user found. Please consult your RT administrator.\n";
         exit 1;
}

my $sc = RT::ScripCondition->new($user);

$sc->Create( Name       => "On Delete",
              Description=> "When a ticket is deleted",
              ExecModule => "OnDelete",
              ApplicableTransTypes=> 'Status',
            );


And then I set a scrip to notify the owner on deletion.  However the 
owner never get a notification.  BTW, my email server works well.

Any suggestion is appreciated.

Wang


More information about the Rt-devel mailing list