<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 12, 2013 at 2:22 PM, Thomas Sibley <span dir="ltr"><<a href="mailto:trs@bestpractical.com" target="_blank">trs@bestpractical.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On 04/12/2013 11:06 AM, Doug Eubanks wrote:<br>
> I apologize, but Perl isn't my strong suit.  :D<br>
><br>
> Changing those three lines still compiles and updates the scrip, but it<br>
> doesn't do anything and never assigns the ticket to anyone now.<br>
<br>
</span>Oh, I see, the previous code was trying to set the owner as the next<br>
user in the array (but may have set an undef owner if the current owner<br>
was the last one in the array).<br>
<br>
I think you'll need to update the code to set $new_owner to the next<br>
owner instead of a random one.  I haven't fully read the scrip though,<br>
so there may be an underlying more fundamental problem.<br>
</blockquote></div><br><br>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.</div><div class="gmail_extra"><br></div><div class="gmail_extra">I used modulo to pick the next owner. Besides that rest of the code is from <a href="http://requesttracker.wikia.com/wiki/AutoSetOwner">http://requesttracker.wikia.com/wiki/AutoSetOwner</a></div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">Description: Auto assign ticket on create</div><div class="gmail_extra">Condition: On Create</div><div class="gmail_extra">Action: User Defined</div><div class="gmail_extra">Template: Global template: Blank</div><div class="gmail_extra">Stage: TransactionCreate</div><div class="gmail_extra"><br></div><div class="gmail_extra">Custom condition: return 1;</div><div class="gmail_extra">Custom action preparation code: return 1;</div><div class="gmail_extra">Custom action cleanup code: </div><div class="gmail_extra"># get out if ticket has a owner</div><div class="gmail_extra">return 1 unless $self->TicketObj->Owner == $RT::Nobody->id;</div><div class="gmail_extra"><br></div><div class="gmail_extra"># gather the list of owners</div><div class="gmail_extra">my @owners = qw( </div><div class="gmail_extra">foo</div><div class="gmail_extra">bar</div><div class="gmail_extra">qaz</div><div class="gmail_extra">);<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">push(@owners, @owners);</div><div class="gmail_extra"><br></div><div class="gmail_extra"># get a count for the owners</div><div class="gmail_extra">my $totmembers = scalar( @owners );</div><div class="gmail_extra"><br></div><div class="gmail_extra"># get this ticket id</div><div class="gmail_extra">my $ticket_id = $self->TicketObj->id;</div><div class="gmail_extra"><br></div><div class="gmail_extra"># ticket_id modulo totmembers to pick the next owner</div><div class="gmail_extra">my $x =  $ticket_id % $totmembers;</div><div class="gmail_extra">my $owner = $owners[$x];</div><div class="gmail_extra"><br></div><div class="gmail_extra"># set the owner</div><div class="gmail_extra">$RT::Logger->info("Auto assign ticket ". $self->TicketObj->id ." to user ". $owner );</div><div class="gmail_extra">my ($status, $msg) = $self->TicketObj->SetOwner( $owner );</div><div class="gmail_extra">unless( $status ) {</div><div class="gmail_extra">    $RT::Logger->error( "Impossible to assign the ticket to $owner: $msg" );</div><div class="gmail_extra">    return undef;</div><div class="gmail_extra">}</div><div class="gmail_extra">return 1;</div></div><div class="gmail_extra"><br></div><div class="gmail_extra"><div><br></div>-- <br><div class="gmail_signature">Asif Iqbal<br>PGP Key: 0xE62693C5 KeyServer: <a href="http://pgp.mit.edu" target="_blank">pgp.mit.edu</a><br>A: Because it messes up the order in which people normally read text.<br>Q: Why is top-posting such a bad thing?<br><br></div>
</div></div>