RT::Action custom scrip - can't locate object method "new"

I am taking my first crack at writing a custom scrip.
Please be forgiving. Naturally, it’s harder if you
don’t know much perl…I

I need to be able to:

  • parse the text of an incoming ticket for a hostname
  • based on a query of custom field, return the ticket
    number of any open tickets for that hostname
  • if so, merge this new ticket with the one that’s
    already open.

I am calling this from a Scrip called
AutoMergeTripwire ("On Create AutoMerge Tripwire
Global Template: Blank). This invokes
RT::Action::AutoMergeTripwire.pm (below). I think I
need to invoke MergeInto, but I know I am doing this
wrong. Also, the RT::Logger doesn’t seems to log
(unless I am not even getting that far?) The following
error is entered in syslog.

Dec 22 15:38:01 myhost RT: Scrip 16 died. - Can’t
locate object method “new” via package
“RT::Action::AutoMergeTripwire” at
/usr/local/rt/lib/RT/ScripAction_Overlay.pm line 146.

Any direction is helpful. My attempt is below…

Sat Dec 20 22:08:50 UTC 2003

When a new ticket is created from a Tripwire

integrity report,

automatically search in same queue, for open

tickets, where RT

custom field is equal to regex pattern match for

$hostname specified

in Tripwire report.

package RT::Action::AutoMergeTripwire;
require RT::Action::Generic;

use DBI;
use strict;
use vars qw/@ISA/;

sub Describe {
my $self = shift;
return (ref $self );

sub Prepare {
return (1);

sub Commit {
my $self = shift;
my $Ticket = $self->TicketObj;
my $ScripObj = $self->ScripObj;
my $Transaction = $self->TransactionObj;
my $Queue = $Ticket->QueueObj->Id;

my $hostname =
($Transaction->Attachments->First->Content =~

$RT::Logger->debug(“hostname from ticket match as

my $query;
my $dbh;
my $sth;
my $openticket;
my $ARGSRef;
if ($hostname) {

my $dbh = DBI->connect('DBI:mysql:rt3:localhost',
                   'rt_user',  # user name
                   '***********',  # password
                   { RaiseError => 0});

$RT::Logger->debug("database connection string:


if (!$dbh) {
#     die "Cannot connect to database" }
$RT::Logger->debug("database connection failed")

my $query = "SELECT Tickets.id
FROM Tickets, Queues, TicketCustomFieldValues,

WHERE Queues.id = ‘$Queue’ AND
CustomFields.Queue = ‘$Queue’ AND
CustomFields.Name = ‘Hostname’ AND
Tickets.Status = ‘open’ AND
TicketCustomFieldValues.Content =
‘$hostname’ AND
TicketCustomFieldValues.Ticket =

$RT::Logger->debug("Query was built as: $query");

my $sth = $dbh->prepare($query);

if (!$sth) {
  #die "Illegal query: $query" };
  $RT::Logger->debug("Illegal query: $query") }

  $sth ->execute();

  while (my @row = $sth->fetchrow_array) {

  if ($row[0]) {
    $openticket = $row[0]);
    $RT::Logger->debug("ticket number is:

$Ticket->MergeInto( $ARGSRef->{ $openticket .
“-MergeInto” } );




Any direction is appreciated. I have searched the
archives and tried to use others’ examples, but no one
is trying to merge tickets from scrips.



Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard