Warning message on set ReferTo

Hi All
I have created a script which has below command to create a link
$Ticket->AddLink(Type=>‘RefersTo’,Target=>$pticket_id,RecordTransactiosn=>0)
;

When I run the script ReferTo link created, but I got below warning as well.
RT version 4.2.8
And line 149 of 02.pl is exit line.

Any idea?

[85829] [Wed Dec 17 07:14:20 2014] [warning]: RT::Handle=HASH(0x802572648)
couldn’t execute the query ‘SELECT * FROM Tickets WHERE id = ?’ at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Handle.pm line 602.

DBIx::SearchBuilder::Handle::SimpleQuery(RT::Handle=HASH(0x802572648),
“SELECT * FROM Tickets WHERE id = ?”, 3311056) called at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record.pm line 1234

DBIx::SearchBuilder::Record::_LoadFromSQL(RT::Ticket=HASH(0x80e255cf0),
“SELECT * FROM Tickets WHERE id = ?”, 3311056) called at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record.pm line 1153

DBIx::SearchBuilder::Record::LoadByCols(RT::Ticket=HASH(0x80e255cf0), “id”,
3311056) called at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record/Cachable.pm
line 120

DBIx::SearchBuilder::Record::Cachable::LoadByCols(RT::Ticket=HASH(0x80e255cf
0), “id”, 3311056) called at /opt/rt4/lib//RT/Record.pm line 396
RT::Record::LoadByCols(RT::Ticket=HASH(0x80e255cf0), “id”, 3311056)
called at /usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record.pm
line 1168
DBIx::SearchBuilder::Record::LoadById(RT::Ticket=HASH(0x80e255cf0),
3311056) called at /opt/rt4/lib//RT/Ticket.pm line 146
RT::ticket::Load(RT::Ticket=HASH(0x80e255cf0), 3311056) called at
/opt/rt4/lib//RT/Ticket.pm line 2581
RT::ticket::_ApplyTransactionBatch(RT::Ticket=HASH(0x80dd1a9f0))
called at /opt/rt4/lib//RT/Ticket.pm line 2569
RT::ticket::ApplyTransactionBatch(RT::Ticket=HASH(0x80dd1a9f0))
called at /opt/rt4/lib//RT/Ticket.pm line 2639
RT::ticket::DESTROY(RT::Ticket=HASH(0x80dd1a9f0)) called at 02.pl
line 149
eval {…} called at 02.pl line 149
(/usr/local/lib/perl5/site_perl/5.14.2/Carp.pm:169)

I can’t see any obvious problems based on your error messages.

There seems to be a typo in the code. Is that directly copied from your
script?

Have you considered enabling debugging from within your script?On Thu, 18 Dec 2014 5:04 am Payam Poursaied me@payam124.com wrote:

Hi All
I have created a script which has below command to create a link
$Ticket->AddLink(Type=>‘RefersTo’,Target=>$pticket_id,
RecordTransactiosn=>0)
;

When I run the script ReferTo link created, but I got below warning as
well.
RT version 4.2.8
And line 149 of 02.pl is exit line.

Any idea?

[85829] [Wed Dec 17 07:14:20 2014] [warning]: RT::Handle=HASH(0x802572648)
couldn’t execute the query ‘SELECT * FROM Tickets WHERE id = ?’ at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Handle.pm line
602.

DBIx::SearchBuilder::Handle::SimpleQuery(RT::Handle=HASH(0x802572648),
“SELECT * FROM Tickets WHERE id = ?”, 3311056) called at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record.pm line
1234

DBIx::SearchBuilder::Record::_LoadFromSQL(RT::Ticket=HASH(0x80e255cf0),
“SELECT * FROM Tickets WHERE id = ?”, 3311056) called at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record.pm line
1153

DBIx::SearchBuilder::Record::LoadByCols(RT::Ticket=HASH(0x80e255cf0),
“id”,
3311056) called at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record/Cachable.
pm
line 120

DBIx::SearchBuilder::Record::Cachable::LoadByCols(RT::
Ticket=HASH(0x80e255cf
0), “id”, 3311056) called at /opt/rt4/lib//RT/Record.pm line 396
RT::Record::LoadByCols(RT::Ticket=HASH(0x80e255cf0), “id”,
3311056)
called at /usr/local/lib/perl5/site_perl/5.14.2/DBIx/
SearchBuilder/Record.pm
line 1168
DBIx::SearchBuilder::Record::LoadById(RT::Ticket=HASH(
0x80e255cf0),
3311056) called at /opt/rt4/lib//RT/Ticket.pm line 146
RT::ticket::Load(RT::Ticket=HASH(0x80e255cf0), 3311056) called at
/opt/rt4/lib//RT/Ticket.pm line 2581
RT::ticket::_ApplyTransactionBatch(RT::Ticket=HASH(0x80dd1a9f0))
called at /opt/rt4/lib//RT/Ticket.pm line 2569
RT::ticket::ApplyTransactionBatch(RT::Ticket=HASH(0x80dd1a9f0))
called at /opt/rt4/lib//RT/Ticket.pm line 2639
RT::ticket::DESTROY(RT::Ticket=HASH(0x80dd1a9f0)) called at 02.pl
line 149
eval {…} called at 02.pl line 149
(/usr/local/lib/perl5/site_perl/5.14.2/Carp.pm:169)

Hi Alex

That line copied exactly from the script.

The whole idea of my script is searching for specific ticket based on customefiled and refer a newly created ticket to the first ticket which has the same customfiled value.

First it fills some customfields based on body of the first transaction and tries then find the first ticket which is similar to that ticket (i.e. has the same value in one of its customfield) and creates a “Refer To” link to that ticket.

Concept is very similar to http://requesttracker.wikia.com/wiki/AddRefersToOnEqualCustomField but instead of putting the code as a “Scrips” I run it as a standalone perl script.

I have put my code and some of the errors below

The only thing which might be relevant to this case is, I have one scrips with user defined condition.

The condition code is in the below table:

return 0 unless $self->TransactionObj->Type eq “Create”;

my $ChatArchiverTo=‘xxxxx@yyyyy.com’;

my $scrip=‘scripname’;

my $TO=“”;

if (defined($self->TransactionObj->Attachments->First->GetHeader(“To”))){

$TO = $self->TransactionObj->Attachments->First->GetHeader(“To”);

}

if($self->TicketObj->Subject =~ m/New App Request/){

return 0;

}

if (($TO =~ /$ChatArchiverTo/i)){

$RT::Logger->debug( “$scrip: $TO found in to”);

return 0;

}

else{

$RT::Logger->debug( “$scrip: $TO was not found in to”);

return 1;

}

my $tickets = new RT::Tickets($RT::SystemUser); # Used to store Ticket search results

$tickets->LimitQueue(VALUE =>‘Appforall’);

$tickets->LimitSubject(VALUE=>‘New App Request’, OPERATOR=>‘=’);

$tickets->LimitId(VALUE=>3234491,OPERATOR=>‘>’);

$tickets->OrderByCols({FIELD=>‘Id’, ORDER =>‘ASC’});

$tickets->LimitCustomField(CUSTOMFIELD => $afa_req_type,

                        OPERATOR    => "!=",

                        VALUE       => $afa_req_type_type);

while (my $Ticket = $tickets->Next) {

 my $customer_id="";

 my $app_name="";

 my $txns = $Ticket->Transactions;

 while (my $txn = $txns->Next ) {

    if ($txn->Type ne 'Create'){

        next;

    }

    my $attachments = RT::Attachments->new($txn->CurrentUser);

    $attachments->Limit( FIELD => 'TransactionID', VALUE => $txn->id );

    $attachments->ContentType (VALUE => 'text/plain');

    $attachments->OrderBy( FIELD => 'Id', ORDER => 'ASC' );

    while ( my $a = $attachments->Next ) {

           if($a->Content =~ /customer_id = (\d+).*app_name = ([^\n]+)/s){

              $customer_id=$1;

              $app_name=$2;

              last;

           }

       }

   }



  if ($customer_id  eq '' or $app_name eq ''){

     print "ERROR: customer_id or app_name for ticket $Ticket->Id did not find\n";

     next;

  }

  my $ptickets =  new RT::Tickets($RT::SystemUser);

  $ptickets->LimitQueue(VALUE =>'Appforall');

  $ptickets->LimitCustomField(CUSTOMFIELD => $afa_req_type,

                        OPERATOR    => "=",

                        VALUE       => $afa_req_type_type);

  $ptickets->LimitCustomField(CUSTOMFIELD => $afa_appname,

                        OPERATOR    => "=",

                        VALUE       => "$app_name");

  $ptickets->LimitId(VALUE=>$Ticket->Id,OPERATOR=>'<');

  $ptickets->LimitId(VALUE=>3234491,OPERATOR=>'>');

  $ptickets->OrderByCols({FIELD=>'Id', ORDER =>'ASC'});

  my $pticket_id='';

  if (my $PTicket=$ptickets->Next){

     $pticket_id=$PTicket->Id;

  }

  print $Ticket->Id,"\t",$customer_id,"\t",$app_name,"PARENT-----$pticket_id\n";



  if (defined($ARGV[0]) and  $ARGV[0] eq 'set'){

  $Ticket->AddCustomFieldValue(Field=>$afa_channel,

                            Value=>$afa_chat,

                             RecordTransaction=>0);

  $Ticket->AddCustomFieldValue(Field=>$afa_req_type,

                            Value=>$afa_req_type_type,

                             RecordTransaction=>0);

  $Ticket->AddCustomFieldValue(Field=>$afa_customerid,

                            Value=>$customer_id,

                             RecordTransaction=>0);

  $Ticket->AddCustomFieldValue(Field=>$afa_appname,

                            Value=>$app_name,

                             RecordTransaction=>0);

  if ($pticket_id ne ''){

     $Ticket->AddLink(Type=>'RefersTo',Target=>$pticket_id,RecordTransactiosn=>0);

  }

  }

} # Ticket loop

$RT::Handle->Disconnect();

exit;

[21743] [Mon Dec 22 08:21:54 2014] [warning]: RT::Handle=HASH(0x802572660) couldn’t execute the query 'SELECT COUNT(DISTINCT main.id) FROM Scrips main JOIN ObjectScrips ObjectScrips_1 ON ( ObjectScrips_1.Scrip = main.id ) JOIN ScripConditions ScripConditions_2 ON ( ScripConditions_2.id = main.ScripCondition ) WHERE (ObjectScrips_1.ObjectId = ‘120’ OR ObjectScrips_1.ObjectId = ‘0’) AND (ObjectScrips_1.Stage = ‘TransactionBatch’) AND (ScripConditions_2.ApplicableTransTypes LIKE ‘%AddLink%’ OR ScripConditions_2.ApplicableTransTypes LIKE ‘%Any%’) AND (main.Disabled = ‘0’) ’ at /usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Handle.pm line 602.

    DBIx::SearchBuilder::Handle::SimpleQuery(RT::Handle=HASH(0x802572660), "SELECT COUNT(DISTINCT main.id) FROM Scrips main JOIN ObjectSc"...) called at /usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder.pm line 295

    DBIx::SearchBuilder::_DoCount(RT::Scrips=HASH(0x80dd41c18)) called at /opt/rt4/lib//RT/SearchBuilder.pm line 996

    RT::SearchBuilder::_DoCount(RT::Scrips=HASH(0x80dd41c18)) called at /usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder.pm line 1471

    DBIx::SearchBuilder::Count(RT::Scrips=HASH(0x80dd41c18)) called at /opt/rt4/lib//RT/Scrips.pm line 495

    RT::Scrips::_FindScrips(RT::Scrips=HASH(0x80dd41c18), "Stage", "TransactionBatch", "Type", "AddLink") called at /opt/rt4/lib//RT/Scrips.pm line 343

    RT::Scrips::Prepare(RT::Scrips=HASH(0x80dd41c18), "Type", "AddLink", "TransactionObj", RT::Transaction=HASH(0x80deae7b0), "Ticket", undef, "TicketObj", RT::Ticket=HASH(0x80dd41600), ...) called at /opt/rt4/lib//RT/Scrips.pm line 291

    RT::Scrips::Apply(RT::Scrips=HASH(0x80dd41c18), "Stage", "TransactionBatch", "TicketObj", RT::Ticket=HASH(0x80dd41600), "TransactionObj", RT::Transaction=HASH(0x80deae7b0), "Type", "AddLink", ...) called at /opt/rt4/lib//RT/Ticket.pm line 2598

    RT::Ticket::_ApplyTransactionBatch(RT::Ticket=HASH(0x80dd41600)) called at /opt/rt4/lib//RT/Ticket.pm line 2569

    RT::Ticket::ApplyTransactionBatch(RT::Ticket=HASH(0x80dd41600)) called at /opt/rt4/lib//RT/Ticket.pm line 2639

    RT::Ticket::DESTROY(RT::Ticket=HASH(0x80dd41600)) called at 02.pl line 149

    eval {...} called at 02.pl line 149 (/usr/local/lib/perl5/site_perl/5.14.2/Carp.pm:169)

[82765] [Thu Dec 25 04:19:52 2014] [warning]: RT::Handle=HASH(0x802572648) couldn’t execute the query ‘SELECT * FROM Tickets WHERE id = ?’ at /usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Handle.pm line 602.

    DBIx::SearchBuilder::Handle::SimpleQuery(RT::Handle=HASH(0x802572648), "SELECT  * FROM Tickets WHERE id = ?", 3330370) called at /usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record.pm line 1234

    DBIx::SearchBuilder::Record::_LoadFromSQL(RT::Ticket=HASH(0x80beca300), "SELECT  * FROM Tickets WHERE id = ?", 3330370) called at /usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record.pm line 1153

    DBIx::SearchBuilder::Record::LoadByCols(RT::Ticket=HASH(0x80beca300), "id", 3330370) called at /usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record/Cachable.pm line 120

    DBIx::SearchBuilder::Record::Cachable::LoadByCols(RT::Ticket=HASH(0x80beca300), "id", 3330370) called at /opt/rt4/lib//RT/Record.pm line 396

    RT::Record::LoadByCols(RT::Ticket=HASH(0x80beca300), "id", 3330370) called at /usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record.pm line 1168

    DBIx::SearchBuilder::Record::LoadById(RT::Ticket=HASH(0x80beca300), 3330370) called at /opt/rt4/lib//RT/Ticket.pm line 146

    RT::Ticket::Load(RT::Ticket=HASH(0x80beca300), 3330370) called at /opt/rt4/lib//RT/Ticket.pm line 2581

    RT::Ticket::_ApplyTransactionBatch(RT::Ticket=HASH(0x80becab88)) called at /opt/rt4/lib//RT/Ticket.pm line 2569

    RT::Ticket::ApplyTransactionBatch(RT::Ticket=HASH(0x80becab88)) called at /opt/rt4/lib//RT/Ticket.pm line 2639

    RT::Ticket::DESTROY(RT::Ticket=HASH(0x80becab88)) called at 02.pl line 149

    eval {...} called at 02.pl line 149 (/usr/local/lib/perl5/site_perl/5.14.2/Carp.pm:169)

[82765] [Thu Dec 25 04:19:52 2014] [warning]: TransactionBatch was fired on a ticket that no longer exists; unable to run scrips! Call ->ApplyTransactionBatch before shredding the ticket, for consistent results. (/opt/rt4/lib//RT/Ticket.pm:2588)From: Alex Peters [mailto:alex@peters.net]
Sent: Wednesday, December 17, 2014 2:31 PM
To: Payam Poursaied; rt-users@lists.bestpractical.com mailto:rt-users@lists.bestpractical.com
Subject: Re: [rt-users] warning message on set ReferTo

I can’t see any obvious problems based on your error messages.

There seems to be a typo in the code. Is that directly copied from your script?

Have you considered enabling debugging from within your script?

The line in your first message:

$Ticket->AddLink(Type=>‘RefersTo’,Target=>$pticket_id,RecordTransactiosn=>0);

has a typo in “RecordTransaction”, but I’m not sure that that parameter
actually applies to the AddLink method. It can probably be removed
altogether. In any case, I don’t think that that is causing any problems.

Your scrip with the user-defined condition (“on create, if ticket subject
is not ‘New App Request’ and To: header does not include xxxxx@yyyyy.com”)
doesn’t seem relevant in this case, since your script doesn’t appear to be
creating tickets.

I notice that you’ve only provided 70 lines of your script (79 lines are
missing). I can’t see any obvious problems with the code you’ve provided.
I suspect that the warnings are being caused by something earlier in the
script.

Out of curiosity, why do you run this code as a standalone script instead
of a scrip? Your script operates specifically on Create transactions, so
wouldn’t it be preferable to create all of the links at the time of ticket
creation?On 25 December 2014 at 19:23, Payam Poursaied me@payam124.com wrote:

Hi Alex

That line copied exactly from the script.

The whole idea of my script is searching for specific ticket based on
customefiled and refer a newly created ticket to the first ticket which has
the same customfiled value.

First it fills some customfields based on body of the first transaction
and tries then find the first ticket which is similar to that ticket (i.e.
has the same value in one of its customfield) and creates a “Refer To” link
to that ticket.

Concept is very similar to
http://requesttracker.wikia.com/wiki/AddRefersToOnEqualCustomField but
instead of putting the code as a “Scrips” I run it as a standalone perl
script.

I have put my code and some of the errors below

The only thing which might be relevant to this case is, I have one scrips
with user defined condition.

The condition code is in the below table:

return 0 unless $self->TransactionObj->Type eq “Create”;

my $ChatArchiverTo=‘xxxxx@yyyyy.com’;

my $scrip=‘scripname’;

my $TO=“”;

if (defined($self->TransactionObj->Attachments->First->GetHeader(“To”))){

$TO = $self->TransactionObj->Attachments->First->GetHeader(“To”);

}

if($self->TicketObj->Subject =~ m/New App Request/){

return 0;

}

if (($TO =~ /$ChatArchiverTo/i)){

$RT::Logger->debug( “$scrip: $TO found in to”);

return 0;

}

else{

$RT::Logger->debug( “$scrip: $TO was not found in to”);

return 1;

}

my $tickets = new RT::Tickets($RT::SystemUser); # Used to store Ticket
search results

$tickets->LimitQueue(VALUE =>‘Appforall’);

$tickets->LimitSubject(VALUE=>‘New App Request’, OPERATOR=>‘=’);

$tickets->LimitId(VALUE=>3234491,OPERATOR=>‘>’);

$tickets->OrderByCols({FIELD=>‘Id’, ORDER =>‘ASC’});

$tickets->LimitCustomField(CUSTOMFIELD => $afa_req_type,

                        OPERATOR    => "!=",

                        VALUE       => $afa_req_type_type);

while (my $Ticket = $tickets->Next) {

 my $customer_id="";

 my $app_name="";

 my $txns = $Ticket->Transactions;

 while (my $txn = $txns->Next ) {

    if ($txn->Type ne 'Create'){

        next;

    }

    my $attachments = RT::Attachments->new($txn->CurrentUser);

    $attachments->Limit( FIELD => 'TransactionID', VALUE => $txn->id );

    $attachments->ContentType (VALUE => 'text/plain');

    $attachments->OrderBy( FIELD => 'Id', ORDER => 'ASC' );

    while ( my $a = $attachments->Next ) {

           if($a->Content =~ /customer_id = (\d+).*app_name =

([^\n]+)/s){

              $customer_id=$1;

              $app_name=$2;

              last;

           }

       }

   }



  if ($customer_id  eq '' or $app_name eq ''){

     print "ERROR: customer_id or app_name for ticket $Ticket->Id did

not find\n";

     next;

  }

  my $ptickets =  new RT::Tickets($RT::SystemUser);

  $ptickets->LimitQueue(VALUE =>'Appforall');

  $ptickets->LimitCustomField(CUSTOMFIELD => $afa_req_type,

                        OPERATOR    => "=",

                        VALUE       => $afa_req_type_type);

  $ptickets->LimitCustomField(CUSTOMFIELD => $afa_appname,

                        OPERATOR    => "=",

                        VALUE       => "$app_name");

  $ptickets->LimitId(VALUE=>$Ticket->Id,OPERATOR=>'<');

  $ptickets->LimitId(VALUE=>3234491,OPERATOR=>'>');

  $ptickets->OrderByCols({FIELD=>'Id', ORDER =>'ASC'});

  my $pticket_id='';

  if (my $PTicket=$ptickets->Next){

     $pticket_id=$PTicket->Id;

  }

  print

$Ticket->Id,“\t”,$customer_id,“\t”,$app_name,“PARENT-----$pticket_id\n”;

  if (defined($ARGV[0]) and  $ARGV[0] eq 'set'){

  $Ticket->AddCustomFieldValue(Field=>$afa_channel,

                            Value=>$afa_chat,

                             RecordTransaction=>0);

  $Ticket->AddCustomFieldValue(Field=>$afa_req_type,

                            Value=>$afa_req_type_type,

                             RecordTransaction=>0);

  $Ticket->AddCustomFieldValue(Field=>$afa_customerid,

                            Value=>$customer_id,

                             RecordTransaction=>0);

  $Ticket->AddCustomFieldValue(Field=>$afa_appname,

                            Value=>$app_name,

                             RecordTransaction=>0);

  if ($pticket_id ne ''){

$Ticket->AddLink(Type=>‘RefersTo’,Target=>$pticket_id,RecordTransactiosn=>0);

  }

  }

} # Ticket loop

$RT::Handle->Disconnect();

exit;

[21743] [Mon Dec 22 08:21:54 2014] [warning]: RT::Handle=HASH(0x802572660)
couldn’t execute the query 'SELECT COUNT(DISTINCT main.id) FROM Scrips
main JOIN ObjectScrips ObjectScrips_1 ON ( ObjectScrips_1.Scrip = main.id
) JOIN ScripConditions ScripConditions_2 ON ( ScripConditions_2.id =
main.ScripCondition ) WHERE (ObjectScrips_1.ObjectId = ‘120’ OR
ObjectScrips_1.ObjectId = ‘0’) AND (ObjectScrips_1.Stage =
‘TransactionBatch’) AND (ScripConditions_2.ApplicableTransTypes LIKE
‘%AddLink%’ OR ScripConditions_2.ApplicableTransTypes LIKE ‘%Any%’) AND
(main.Disabled = ‘0’) ’ at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Handle.pm line 602.

DBIx::SearchBuilder::Handle::SimpleQuery(RT::Handle=HASH(0x802572660),
“SELECT COUNT(DISTINCT main.id) FROM Scrips main JOIN ObjectSc”…)
called at /usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder.pm line
295

    DBIx::SearchBuilder::_DoCount(RT::Scrips=HASH(0x80dd41c18)) called

at /opt/rt4/lib//RT/SearchBuilder.pm line 996

    RT::SearchBuilder::_DoCount(RT::Scrips=HASH(0x80dd41c18)) called

at /usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder.pm line 1471

    DBIx::SearchBuilder::Count(RT::Scrips=HASH(0x80dd41c18)) called at

/opt/rt4/lib//RT/Scrips.pm line 495

    RT::Scrips::_FindScrips(RT::Scrips=HASH(0x80dd41c18), "Stage",

“TransactionBatch”, “Type”, “AddLink”) called at /opt/rt4/lib//RT/Scrips.pm
line 343

    RT::Scrips::Prepare(RT::Scrips=HASH(0x80dd41c18), "Type",

“AddLink”, “TransactionObj”, RT::Transaction=HASH(0x80deae7b0), “Ticket”,
undef, “TicketObj”, RT::Ticket=HASH(0x80dd41600), …) called at
/opt/rt4/lib//RT/Scrips.pm line 291

    RT::Scrips::Apply(RT::Scrips=HASH(0x80dd41c18), "Stage",

“TransactionBatch”, “TicketObj”, RT::Ticket=HASH(0x80dd41600),
“TransactionObj”, RT::Transaction=HASH(0x80deae7b0), “Type”, “AddLink”,
…) called at /opt/rt4/lib//RT/Ticket.pm line 2598

    RT::Ticket::_ApplyTransactionBatch(RT::Ticket=HASH(0x80dd41600))

called at /opt/rt4/lib//RT/Ticket.pm line 2569

    RT::Ticket::ApplyTransactionBatch(RT::Ticket=HASH(0x80dd41600))

called at /opt/rt4/lib//RT/Ticket.pm line 2639

    RT::Ticket::DESTROY(RT::Ticket=HASH(0x80dd41600)) called at 02.pl

line 149

    eval {...} called at 02.pl line 149

(/usr/local/lib/perl5/site_perl/5.14.2/Carp.pm:169)

[82765] [Thu Dec 25 04:19:52 2014] [warning]: RT::Handle=HASH(0x802572648)
couldn’t execute the query ‘SELECT * FROM Tickets WHERE id = ?’ at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Handle.pm line 602.

DBIx::SearchBuilder::Handle::SimpleQuery(RT::Handle=HASH(0x802572648),
“SELECT * FROM Tickets WHERE id = ?”, 3330370) called at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record.pm line 1234

DBIx::SearchBuilder::Record::_LoadFromSQL(RT::Ticket=HASH(0x80beca300),
“SELECT * FROM Tickets WHERE id = ?”, 3330370) called at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record.pm line 1153

DBIx::SearchBuilder::Record::LoadByCols(RT::Ticket=HASH(0x80beca300), “id”,
3330370) called at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record/Cachable.pm
line 120

DBIx::SearchBuilder::Record::Cachable::LoadByCols(RT::Ticket=HASH(0x80beca300),
“id”, 3330370) called at /opt/rt4/lib//RT/Record.pm line 396

    RT::Record::LoadByCols(RT::Ticket=HASH(0x80beca300), "id",
  1. called at
    /usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record.pm line 1168

DBIx::SearchBuilder::Record::LoadById(RT::Ticket=HASH(0x80beca300),
3330370) called at /opt/rt4/lib//RT/Ticket.pm line 146

    RT::Ticket::Load(RT::Ticket=HASH(0x80beca300), 3330370) called at

/opt/rt4/lib//RT/Ticket.pm line 2581

    RT::Ticket::_ApplyTransactionBatch(RT::Ticket=HASH(0x80becab88))

called at /opt/rt4/lib//RT/Ticket.pm line 2569

    RT::Ticket::ApplyTransactionBatch(RT::Ticket=HASH(0x80becab88))

called at /opt/rt4/lib//RT/Ticket.pm line 2639

    RT::Ticket::DESTROY(RT::Ticket=HASH(0x80becab88)) called at 02.pl

line 149

    eval {...} called at 02.pl line 149

(/usr/local/lib/perl5/site_perl/5.14.2/Carp.pm:169)

[82765] [Thu Dec 25 04:19:52 2014] [warning]: TransactionBatch was fired
on a ticket that no longer exists; unable to run scrips! Call
->ApplyTransactionBatch before shredding the ticket, for consistent
results. (/opt/rt4/lib//RT/Ticket.pm:2588)

From: Alex Peters [mailto:alex@peters.net alex@peters.net]
Sent: Wednesday, December 17, 2014 2:31 PM
To: Payam Poursaied; rt-users@lists.bestpractical.com
Subject: Re: [rt-users] warning message on set ReferTo

I can’t see any obvious problems based on your error messages.

There seems to be a typo in the code. Is that directly copied from your
script?

Have you considered enabling debugging from within your script?

On Thu, 18 Dec 2014 5:04 am Payam Poursaied me@payam124.com wrote:

Hi All
I have created a script which has below command to create a link

$Ticket->AddLink(Type=>‘RefersTo’,Target=>$pticket_id,RecordTransactiosn=>0)
;

When I run the script ReferTo link created, but I got below warning as
well.
RT version 4.2.8
And line 149 of 02.pl is exit line.

Any idea?

[85829] [Wed Dec 17 07:14:20 2014] [warning]: RT::Handle=HASH(0x802572648)
couldn’t execute the query ‘SELECT * FROM Tickets WHERE id = ?’ at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Handle.pm line
602.

DBIx::SearchBuilder::Handle::SimpleQuery(RT::Handle=HASH(0x802572648),
“SELECT * FROM Tickets WHERE id = ?”, 3311056) called at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record.pm line
1234

DBIx::SearchBuilder::Record::_LoadFromSQL(RT::Ticket=HASH(0x80e255cf0),
“SELECT * FROM Tickets WHERE id = ?”, 3311056) called at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record.pm line
1153

DBIx::SearchBuilder::Record::LoadByCols(RT::Ticket=HASH(0x80e255cf0), “id”,
3311056) called at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record/Cachable.pm
line 120

DBIx::SearchBuilder::Record::Cachable::LoadByCols(RT::Ticket=HASH(0x80e255cf
0), “id”, 3311056) called at /opt/rt4/lib//RT/Record.pm line 396
RT::Record::LoadByCols(RT::Ticket=HASH(0x80e255cf0), “id”, 3311056)
called at
/usr/local/lib/perl5/site_perl/5.14.2/DBIx/SearchBuilder/Record.pm
line 1168
DBIx::SearchBuilder::Record::LoadById(RT::Ticket=HASH(0x80e255cf0),
3311056) called at /opt/rt4/lib//RT/Ticket.pm line 146
RT::ticket::Load(RT::Ticket=HASH(0x80e255cf0), 3311056) called at
/opt/rt4/lib//RT/Ticket.pm line 2581
RT::ticket::_ApplyTransactionBatch(RT::Ticket=HASH(0x80dd1a9f0))
called at /opt/rt4/lib//RT/Ticket.pm line 2569
RT::ticket::ApplyTransactionBatch(RT::Ticket=HASH(0x80dd1a9f0))
called at /opt/rt4/lib//RT/Ticket.pm line 2639
RT::ticket::DESTROY(RT::Ticket=HASH(0x80dd1a9f0)) called at 02.pl
line 149
eval {…} called at 02.pl line 149
(/usr/local/lib/perl5/site_perl/5.14.2/Carp.pm:169)