[rt-users] round-robin auto assignment?

Andy Harrison aharrison at gmail.com
Tue Dec 28 17:37:07 EST 2004


On Tue, 28 Dec 2004 13:47:17 -0800, matthew zeier <mrz at intelenet.net> wrote:
> 
> I've done a little more work on this with Chance (scrip below).  We're
> getting the following error with $Ticket:
> 
> [Tue Dec 28 21:45:58 2004] [error]: Scrip 57 Prepare failed: Global symbol
> "$Ticket" requires explicit package name at (eval 2333) line 6.
> Global symbol "$Ticket" requires explicit package name at (eval 2333) line
> 18.
> Global symbol "$Ticket" requires explicit package name at (eval 2333) line
> 24.
> syntax error at (eval 2333) line 24, near "->SetOwner["
>  (/opt/rt3/lib/RT/Action/UserDefined.pm:65)
> 
> 
> How do I refer to the current ticket?
> 
> ----
> 
> my @owners = qw( 2306 904 1880 ); #could create a group for this
> push(@owners, @owners);
> 
> my $tickets = RT::Tickets->new($RT::System);
> $tickets->LimitQueue(VALUE => 'ICI Internal');
> $tickets->LimitId(VALUE => $Ticket->Id, OPERATOR => '!=');
> $tickets->OrderBy( FIELD => 'id', ORDER => 'DESC' );
> my $last_ticket = $tickets->First;
> my $last_owner = $last_ticket->Owner->Id;
> 
> my $i = 0;
> my $isSet = 0;
> my $new_owner;
> 
> foreach $i ( @owners) {
>     if ($owners[$i] == $last_owner) {
>         $new_owner = $owners[$i+1];
>         $Ticket->SetOwner($new_owner);
>         $isSet = 1;
>     }
> }
> 
> if (!($isSet)) {
>     $Ticket->SetOwner[int(rand($#owners))];
> }
> 

You have to iterate the collection of tickets.  

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

-- 
Andy Harrison



More information about the rt-users mailing list