[rt-users] round-robin auto assignment - DONE
matthew zeier
mrz at intelenet.net
Tue Dec 28 21:22:14 EST 2004
Thanks to everyone who helped with this. The working scrip is below. If
the last owner isn't one of the owners to round-robin through, a random
owner is picked. Ideally, @owners would be an RT group and somehow
magically work, but that's for the next rev.
my @owners = qw( 752 82040 ); # need to grab id from Users table
push(@owners, @owners);
my $tickets = RT::Tickets->new($RT::SystemUser);
$tickets->LimitQueue(VALUE => 'Sales'); # my queue, yours may differ
$tickets->LimitId(VALUE => $self->TicketObj->Id, OPERATOR => '!=');
$tickets->OrderBy( FIELD => 'id', ORDER => 'DESC' );
my $last_ticket = $tickets->First;
my $last_owner = $last_ticket->Owner;
my $i = 0;
my $isSet = 0;
my $new_owner;
foreach $i ( @owners) {
if ($owners[$i] == $last_owner) {
$new_owner = $owners[$i+1];
$self->TicketObj->SetOwner($new_owner);
$isSet = 1;
}
}
if (!($isSet)) {
my $randOwner = int(rand($#owners));
$randOwner = $owners[$randOwner];
$self->TicketObj->SetOwner($randOwner);
}
More information about the rt-users
mailing list