[rt-users] round-robin auto assignment?

Doug Eubanks admin at dougware.net
Fri Apr 12 11:20:20 EDT 2013


Sorry to dig an old thread up, but I'm looking at this URL:
http://www.gossamer-threads.com/lists/rt/users/39136

This scrip works, but seems to always pick a random user from the list, it
appears that's not matching on one of these two lines:

foreach $i ( @owners) {
if ($owners[$i] == $last_owner) {

Here is the complete scrip that I am using:
my @owners = qw( 1640 15482 22087 8674 ); # 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);
}

Any help or suggestions would be great!
Thanks,
Doug Eubanks
admin at dougware.net
K1DUG
(919) 201-8750
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20130412/928ceffe/attachment.htm>


More information about the rt-users mailing list