[Rt-devel] Question about user defined condition

lwang lwang at clusterfs.com
Thu Nov 17 22:10:31 EST 2005


Grossman,
Yes, you are right.  It works after I change the code.

"RT Essentials" by O'Reilly tells me wrong story.  :(

Wang

Rolf Grossmann wrote:
> My guess would be that TicketObj still has the old status when the scrip
> is running. Haven't checked though.
> 
> Is there a reason you didn't use the StatusChange Condition similar to
> On Resolve? That's what I would have done.
> 
> Rolf.
> 
> lwang wrote:
> 
>>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
>>_______________________________________________
>>Rt-devel mailing list
>>Rt-devel at lists.bestpractical.com
>>http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel



More information about the Rt-devel mailing list