[rt-users] [FOLLOWUP] Finding a ticket queue moves

Ernesto Hernandez-Novich emhnemhn at gmail.com
Sat Nov 29 23:40:33 EST 2008


On Mon, 2008-11-24 at 16:38 -0430, Ernesto Hernandez-Novich wrote:
> On Thu, 2008-10-23 at 10:15 -0430, Ernesto Hernandez-Novich wrote:
> > I have a "master" queue where almost everyone sends requests. A clerk
> > looks at the tickets there and then places them in a different queue for
> > processing. I'd like to have a query/report that shows the ticket, the
> > queue it is currently in, and the queue it originated from if different
> > from the current queue.
[...]
> that brings the exact information needed by the report given a ticket
> number as the single parameter. Now I need to turn this into an RT
> custom Report, and so far I've been able to create the form to get the
> value of the ticket and place it in the Reports tab, but so far I
> haven't been able to figure out how to translate the SQL query into RT's
> API (if possible).

I finally managed to get the report quite right; there was an additional
requirement since tickets may move more than once (enters "General",
then gets moved to "DBAs", then moved onto "Applications" and so on
until closed). Having a single ticket number in $TicketNumber, I wrote
the query to find all the "move" transactions as follows:

my $Ticket = RT::Ticket->new( $session{'CurrentUser'} );
$Ticket->LoadById( $TicketNumber );
my $Transactions = $Ticket->Transactions();
$Transactions->Limit( 
  FIELD => 'Type', OPERATOR => '=', VALUE => 'Set',
  ENTRYAGGREGATOR => 'AND'
);
$Transactions->Limit(
  FIELD => 'Filed', OPERATOR => '=', VALUE => 'Queue',
  ENTRYAGGREGATOR => 'AND'
);
$Transactions->OrderBy( FIELD => 'Created' );
while ( my $t = $Transactions->Next() ) {
  my $srcQueue = RT::Queue->new( $session{'CurrentUser'} );
     $srcQueue->LoadById( $t->OldValue );
  my $dstQueue = RT::Queue->new( $session{'CurrentUser'} );
     $dstQueue->LoadById( $t->NewValue );
  print "Moved from ", $srcQueue->Name,
        " to ", $dstQueue->Name,
        " on ", $t->Created,
        " by ", $t->CreatorObj->Name;
}

Comments and suggestions for improvement are welcome :-)
-- 
Ernesto Hernández-Novich - Linux 2.6.18 i686 - Unix: Live free or die!
Geek by nature, Linux by choice, Debian of course.
If you can't aptitude it, it isn't useful or doesn't exist.
GPG Key Fingerprint = 438C 49A2 A8C7 E7D7 1500 C507 96D6 A3D6 2F4C 85E3




More information about the rt-users mailing list