[rt-users] round-robin auto assignment?

Asif Iqbal vadud3 at gmail.com
Thu Oct 22 11:12:27 EDT 2015


On Fri, Apr 12, 2013 at 2:22 PM, Thomas Sibley <trs at bestpractical.com>
wrote:

> On 04/12/2013 11:06 AM, Doug Eubanks wrote:
> > I apologize, but Perl isn't my strong suit.  :D
> >
> > Changing those three lines still compiles and updates the scrip, but it
> > doesn't do anything and never assigns the ticket to anyone now.
>
> Oh, I see, the previous code was trying to set the owner as the next
> user in the array (but may have set an undef owner if the current owner
> was the last one in the array).
>
> I think you'll need to update the code to set $new_owner to the next
> owner instead of a random one.  I haven't fully read the scrip though,
> so there may be an underlying more fundamental problem.
>


I were able to get it working with modulo. Here is the complete scrip we
are running since today and so far looks good. Any suggestion is welcome to
improve it.

I used modulo to pick the next owner. Besides that rest of the code is from
http://requesttracker.wikia.com/wiki/AutoSetOwner

Description: Auto assign ticket on create
Condition: On Create
Action: User Defined
Template: Global template: Blank
Stage: TransactionCreate

Custom condition: return 1;
Custom action preparation code: return 1;
Custom action cleanup code:
# get out if ticket has a owner
return 1 unless $self->TicketObj->Owner == $RT::Nobody->id;

# gather the list of owners
my @owners = qw(
foo
bar
qaz
);

push(@owners, @owners);

# get a count for the owners
my $totmembers = scalar( @owners );

# get this ticket id
my $ticket_id = $self->TicketObj->id;

# ticket_id modulo totmembers to pick the next owner
my $x =  $ticket_id % $totmembers;
my $owner = $owners[$x];

# set the owner
$RT::Logger->info("Auto assign ticket ". $self->TicketObj->id ." to user ".
$owner );
my ($status, $msg) = $self->TicketObj->SetOwner( $owner );
unless( $status ) {
    $RT::Logger->error( "Impossible to assign the ticket to $owner: $msg" );
    return undef;
}
return 1;


-- 
Asif Iqbal
PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20151022/7bc8a46a/attachment.html>


More information about the rt-users mailing list