[rt-devel] Problem accessing attachments on Queue Change (in a scrip)

Kouprie, Robbert R.Kouprie at DTO.TUDelft.NL
Tue Apr 6 11:31:23 EDT 2004


Hi all,
 
I'm running RT 3.0.10 and I am trying to setup a scrip that reads the
original e-mail *on queue change*, and pulls information from it (for
example to fill in some CustomFields). However I ran into some problems
accessing the original e-mail content.
 
I've tried different scrips, including some self-written ones from examples
on the rt-users list, and also the ExtractCustomFieldValues scrip (from
http://page.mi.fu-berlin.de/~pape/rt3/ExtractCustomFieldValues.tgz
<http://page.mi.fu-berlin.de/~pape/rt3/ExtractCustomFieldValues.tgz> ), but
I keep having the same problem: $self->TransactionObj->Attachments->First is
always empty!
 
The database contents is ok, and I never ran anything (like perl <5.8) that
corrupted it.
 
I tried this home-made scrip:
 
Condition: On Queue Change
Custom Condition: (empty)
Action: User Defined
Custom action preparation code:
 
1;
 
Custom action cleanup code:
 
require RT::Action::Generic;
use strict;
use vars qw/@ISA/ <mailto:qw/@ISA/> ;
@ISA=qw(RT::Action::Generic);
my $messages = $self->TransactionObj->Attachments;
 
if (not $messages->First) {
  $RT::Logger->debug("Can't find ticket's first e-mail!");
  return 1;
} else {
    $RT::Logger->debug("OK");
}
return 1;
 
Stage: TransactionCreate
 
With this scrip I _always_ get "Can't find ticket's first e-mail!". The
problem seems to be that the Transaction that is created *on queue change*
doesn't return anything when questioned for Attachments.
 
However, when I replace:
    my $messages = $self->TransactionObj->Attachments;
with:
    my $messages = $self->TicketObj->Transactions->First->Attachments;
the scrip is referring to the original "create" Transaction, and the
Attachments *will* be found.
 
Is this wanted behaviour, and why is this the case? Why is an Attachment a
property of a Transaction, instead of a Ticket? Is there a short way to
access all Attachments of a Ticket, regardless of which Transactions they're
in?
 
Thanks in advance,
Robbert
 
--
Robbert Kouprie
Technical University of Delft
The Netherlands
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://pallas.eruditorum.org/pipermail/rt-devel/attachments/20040406/73b0c3d5/attachment.htm


More information about the Rt-devel mailing list