[rt-users] scanning active ticket contents in perl
Ruslan Zakirov
ruslan.zakirov at gmail.com
Tue Sep 8 18:34:40 EDT 2009
Hello Eden,
On Wed, Sep 9, 2009 at 1:58 AM, Robert Eden<rmeden at gmail.com> wrote:
> Howdy all...
>
> I'd like to write a special report and in order to do so, I need to get
> info from scanning replies and comments of tickets.
>
> This shouldn't be hard, but I just can't figure it out. I've read the
> RT Essentials book, the wiki, some sample code... I'm close... just
> can't seem to close the deal!
>
> My first question is where should I be looking for this sort of info? I
> couldn't find any sample code for offline reporting. I find that
> strange. I also can't find all the methods and attributes of the RT
> objects documented anywhere.
>
> Here's my code snippet. The Transactions->Next seems to be looping
> rather than stepping through each transaction.
Sure, the code is looping as $ticket->Transactions each time returns
new collection, so you always start from first txn. You need somthing
like:
my $txns = $ticket->Transactions;
while ( my $txn = $txns->Next ) {
...
}
> $tickets->LimitStatus(VALUE => 'new');
> $tickets->LimitStatus(VALUE => 'open');
>
> while (my $Ticket = $tickets->Next) {
> print "Ticket ".$Ticket->id."\n";
> while (my $txn = $Ticket->Transactions->Next) {
> print "Txn ".$txn->id."\n";
> my $attachments = RT::Attachments->new($txn->CurrentUser);
> $attachments->Limit( FIELD => 'TransactionID', VALUE => $txn->id );
> $attachments->OrderBy( FIELD => 'Id', ORDER => 'ASC' );
> while ( my $a = $attachments->Next ) {
> print "ContentType=".$a->ContentType."\n";
> print "ContentEncoding=".$a->ContentEncoding."\n";
> print "Content:".substr($a->Content,0,100)."\n";
> }
> }
> die "stop here" if $count++>5;
> }
>
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
>
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
>
--
Best regards, Ruslan.
More information about the rt-users
mailing list