<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Arial; font-size: 10pt; color: #000000'><P>List,</P>
<P> </P>
<P>I recently created a custom condition to match tickets created after hours so that I could use it in a scrip to send a copy of the ticket information to the on-call Support Desk tech.  I first tested it successfully on an old RT 3.8.8 installation and then started testing it in my RT 4.0.2 installation.  I get the following error:</P>
<P> </P>
<P>Oct 13 22:20:57 rt2 RT: Scrip IsApplicable 14 died. - Can't locate object method "new" via package "RT::Condition::OnAfterHoursCreate" at /usr/local/rt/sbin/../lib/RT/ScripCondition.pm line 173.  Stack:   [/usr/local/rt/sbin/../lib/RT/ScripCondition.pm:173]   [/usr/local/rt/sbin/../lib/RT/Scrip.pm:404]   [/usr/local/rt/sbin/../lib/RT/Scrips.pm:225]   [/usr/local/rt/sbin/../lib/RT/Transaction.pm:179]   [/usr/local/rt/sbin/../lib/RT/Record.pm:1447]   [/usr/local/rt/sbin/../lib/RT/Ticket.pm:669]   [/usr/local/rt/sbin/../lib/RT/Interface/Web.pm:1389]   [/usr/local/rt/share/html/Ticket/Display.html:127]   [/usr/local/rt/share/html/Ticket/Create.html:444]   [/usr/local/rt/sbin/../lib/RT/Interface/Web.pm:538]   [/usr/local/rt/sbin/../lib/RT/Interface/Web.pm:285]   [/usr/local/rt/share/html/autohandler:53] (/usr/local/rt/sbin/../lib/RT/Scrip.pm:419)<BR><BR>The name of the custom condition is OnAfterHoursCreate and it is located under <myRtRoot>/local/lib/RT/Condition/.  What's odd is that when I look at the system condition modules, I don't see a new() method defined so I'm not sure why this error is occuring for me.  For reference, this is the code for the custom condition:</P>
<P> </P>
<P>package RT::Condition::OnAfterHoursCreate;</P>
<P> </P>
<P>use warnings;<BR>use strict;</P>
<P>use base 'RT::Condition';</P>
<P> </P>
<P>sub IsApplicable {</P>
<P>        my $self = shift;</P>
<P>        my $weekday = (localtime)[6];<BR>        my $min = (localtime)[1];<BR>        my $hour = (localtime)[2];</P>
<P>        return 1 if $weekday == 6 || $weekday == 0;<BR>        return 1 if $hour >= 17 || ( $hour <= 8 && $min <= 29);</P>
<P>        return 0;       # no match</P>
<P>}</P>
<P>1;<BR></P>
<P>I used the following Perl script to register the condition within RT:</P>
<P> </P>
<P>#!/usr/bin/perl</P>
<P>use strict;</P>
<P>use lib "/usr/local/rt/lib";</P>
<P> </P>
<P>use RT;</P>
<P>use RT::Interface::CLI qw( CleanEnv GetCurrentUser );</P>
<P>use RT::ScripCondition;</P>
<P>CleanEnv();</P>
<P>RT::LoadConfig();</P>
<P>RT::Init();</P>
<P> </P>
<P>my $user = GetCurrentUser();</P>
<P>unless( $user->Id ) {</P>
<P>    print "No RT user found. Please consult your RT administrator.\n";</P>
<P>    exit 1;</P>
<P>}</P>
<P> </P>
<P>my $sc = RT::ScripCondition->new($user);</P>
<P>$sc->Create( Name                 => 'On After Hours Create',</P>
<P>             Description          => 'A ticket is created after hours',</P>
<P>             ExecModule           => 'OnAfterHoursCreate',</P>
<P>             ApplicableTransTypes => 'Create',</P>
<P>           );<BR></P>
<P>I built the custom condition and registration code from an example I found in the 'RT Essentials' book published by O'Reilly.  In fact, it's a 99% lift from that book.  The only difference I noted that was required for custom conditions in RT 4 was the need to change "use base 'RT::Condition:Generic';" to "use base 'RT::Condition';".</P>
<P> </P>
<P>Am I missing something in general?  Or am I missing something specific to RT 4?</P>
<P> </P>
<P>Ryan</P></div></body></html>