Make RT aware of ScripCondition modules - alternate methods?

I created a custom scrip Action module
(/my-rt-directory/local/lib/RT/Action/AddDept.pm) that I would like to
make RT aware of so that I can call it from scrips.

Using the example from “RT Essentials” at the bottom of page 79, I
created an executable and ran it to “register” a module. This worked
great on my test box (RT 3.4.4 basic setup), but failed on my production
box (RT 3.3.2 that relies on apache ldap authentication).

I think my problems lies in that I can’t get “bin/rt”, the CLI to work
on my production box which uses Apache/LDAP authentication.

Are there any other ways to register the module other than rely on the CLI?

Error I get:
[Thu Jan 26 00:56:36 2006] [crit]: Can’t locate object method “new” via
package “RT::ScripAction” (perhaps you forgot to load
"RT::ScripAction"?) at ./register_module.pl line 21.
(/usr/local/rt3/lib/RT.pm:276)

Details of my “register.pl” executable:
#!/usr/bin/perl

use strict;
use lib “/usr/local/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;
}
#hack

$user = “root”;

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

$sc->Create( Name => ‘Add Department’,
Description => ‘set department custom field for new
tickets’,
ExecModule => ‘AddDepartment’,
);

Mike Patterson
Systems Manager
UC Berkeley Extension

Before I tell you how to fix it, take a harder look at the error
message, then at your code. I’ve pulled out the bits that matter.

Error I get:

[Thu Jan 26 00:56:36 2006] [crit]: Can’t locate object method “new” via > package “RT::ScripAction” (perhaps you forgot to load “RT::ScripAction”?) at ./register_module.pl line 21.

Details of my “register.pl” executable:

use RT::ScripCondition;

Thanks again for helping me with my perl homework Uncle Jesse :slight_smile: .

That’s a pretty informative error message too…

Now that you’ve taught me to “fish” a previously unused part of my
brain has made a connection between reading error messages and "use"
statements.

I was confused because my sloppy code copied from my 3.4.4 test box
seemed to work fine, while the same code on 3.2.2 box wasn’t going to go
for it…

In case it wasn’t blatantly obvious to everyone reading this list, I
needed to:
use RT::ScripAction;
instead of
use RT::ScripCondition;

Mike Patterson
Systems Manager
UC Berkeley Extension