Round-robin auto assignment?

Would like to auto assign incoming “sales” tickets amongst users in the
"sales" group. I imagine that’s possible with an On-Create but I’m not sure
what that code would look like.

Has anyone already invented this wheel?

The scrip needs to figure out the last ticket created in the
queue, figure out who it was assigned to, and then assign
to the next person in a list that is also stored in the
scrip.

Here is a start but there may be subtle bugs:

my @owners = qw( george sam bill fred ); #could create a group for this
push(@owners, @owners);

my $tickets = RT::Tickets->new($RT::System);
$tickets->LimitQueue(VALUE => ‘my queue’);
$tickets->LimitId(VALUE => $Ticket->Id, OPERATOR => ‘!=’);
$tickets->OrderBy( FIELD => ‘id’, ORDER => ‘DESC’ );
my $last_ticket = $tickets->First;
my $last_owner = $last_ticket->Owner->Name;

my $i = 0;
my $new_owner;

while (1) {
if ($owners[$i] eq $last_owner) {
$new_owner = $owners[$i+1];
$Ticket->SetOwner($new_owner);
last;
}
}On Wed, Dec 15, 2004 at 01:30:02PM -0800, matthew zeier wrote:

Would like to auto assign incoming “sales” tickets amongst users in the
"sales" group. I imagine that’s possible with an On-Create but I’m not
sure what that code would look like.

Has anyone already invented this wheel?


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Be sure to check out the RT wiki at http://wiki.bestpractical.com

Condition: On Create
Action: User Defined
Template: blank
Stage: TransactionCreate

I pasted what you had into “Custom action prep code” . Its a scrip just
for a particular queue. I’m seeing the following error:

[Wed Dec 15 23:35:51 2004] [error]: Scrip 57 Prepare failed: Global symbol
"$Ticket" requires explicit package name at (eval 2222) line 6.
Global symbol “$Ticket” requires explicit package name at (eval 2222) line
17.
(/opt/rt3/lib/RT/Action/UserDefined.pm:65)

What’s the right way to reference $Ticket?

my @owners = qw( mrz jstein vzwick ); #could create a group for this
push(@owners, @owners);

my $tickets = RT::Tickets->new($RT::System);
$tickets->LimitQueue(VALUE => ‘my queue’);
$tickets->LimitId(VALUE => $Ticket->Id, OPERATOR => ‘!=’);
$tickets->OrderBy( FIELD => ‘id’, ORDER => ‘DESC’ );
my $last_ticket = $tickets->First;
my $last_owner = $last_ticket->Owner->Name;

my $i = 0;
my $new_owner;

while (1) {
if ($owners[$i] eq $last_owner) {
$new_owner = $owners[$i+1];
$Ticket->SetOwner($new_owner);
last;
}
}

I forgot to change ‘my queue’ to something more meaningful. However, I
don’t think this scrip is even being called. Here’s my log output:

[Thu Dec 16 04:37:35 2004] [debug]: About to think about scrips for
transaction147917 (/opt/rt3/lib/RT/Transaction_Overlay.pm:140)
[Thu Dec 16 04:37:35 2004] [debug]: About to prepare scrips for
transaction147917 (/opt/rt3/lib/RT/Transaction_Overlay.pm:144)
[Thu Dec 16 04:37:35 2004] [debug]: Found 4 scrips
(/opt/rt3/lib/RT/Scrips_Overlay.pm:349)
[Thu Dec 16 04:37:35 2004] [debug]: Converting ‘utf-8’ to 'us-ascii’
for text/plain - [intelenet.net #26582] t2
(/opt/rt3/lib/RT/I18N.pm:222)
[Thu Dec 16 04:37:35 2004] [debug]: Converting ‘utf-8’ to 'us-ascii’
for text/plain - [intelenet.net #26582] t2
(/opt/rt3/lib/RT/I18N.pm:222)
[Thu Dec 16 04:37:36 2004] [debug]: About to commit scrips for
transaction147917 (/opt/rt3/lib/RT/Transaction_Overlay.pm:153)
[Thu Dec 16 04:37:36 2004] [info]:
rt-3.2.2-26582-147917-3.10.6204116387742@intelenet.net #26582/147917

Condition: On Create
Action: User Defined
Template: blank
Stage: TransactionCreate

I pasted what you had into “Custom action prep code” . Its a scrip
just for a particular queue. I’m seeing the following error:

[Wed Dec 15 23:35:51 2004] [error]: Scrip 57 Prepare failed: Global
symbol “$Ticket” requires explicit package name at (eval 2222) line 6.
Global symbol “$Ticket” requires explicit package name at (eval 2222)
line 17.
(/opt/rt3/lib/RT/Action/UserDefined.pm:65)

What’s the right way to reference $Ticket?

my @owners = qw( mrz jstein vzwick ); #could create a group for this
push(@owners, @owners);

my $tickets = RT::Tickets->new($RT::System);
$tickets->LimitQueue(VALUE => ‘my queue’);
$tickets->LimitId(VALUE => $Ticket->Id, OPERATOR => ‘!=’);
$tickets->OrderBy( FIELD => ‘id’, ORDER => ‘DESC’ );
my $last_ticket = $tickets->First;
my $last_owner = $last_ticket->Owner->Name;

my $i = 0;
my $new_owner;

while (1) {
if ($owners[$i] eq $last_owner) {
$new_owner = $owners[$i+1];
$Ticket->SetOwner($new_owner);
last;
}
}


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Be sure to check out the RT wiki at http://wiki.bestpractical.com

matthew zeier - “Nothing in life is to be feared. It is only to be
understood.” - Marie Curie

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))];
}

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

How do I refer to the current ticket?

if (!($isSet)) {
$Ticket->SetOwner[int(rand($#owners))];
}

You have to iterate the collection of tickets.

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

}

Why? You mean I have to re-search the queue to find the ticket I’m in the
midst of creating?

That’s seems like a horribly complicated method to get the current ticket’s
object.

Try:

$Transaction->TicketObj->SetOwnerOn Tue, Dec 28, 2004 at 01:47:17PM -0800, matthew zeier 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))];
}


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Be sure to check out the RT wiki at http://wiki.bestpractical.com

$Transaction->TicketObj->SetOwner

Similiar error.

[Tue Dec 28 23:01:49 2004] [error]: Scrip 57 Prepare failed: Global symbol
"$Ticket" requires explicit package name at (eval 2195) line 6.
Global symbol “$Transaction” requires explicit package name at (eval 2195)
line 18.
Global symbol “$Transaction” requires explicit package name at (eval 2195)
line 24.
syntax error at (eval 2195) line 24, near “->SetOwner[”
(/opt/rt3/lib/RT/Action/UserDefined.pm:65)

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];
$Transaction->TicketObj->SetOwner($new_owner);
$isSet = 1;
}
}

if (!($isSet)) {
$Transaction->TicketObj->SetOwner[int(rand($#owners))];
}

Sorry. Use this:

$self->TicketObj->SetOwnerOn Tue, Dec 28, 2004 at 03:03:14PM -0800, matthew zeier wrote:

$Transaction->TicketObj->SetOwner

Similiar error.

[Tue Dec 28 23:01:49 2004] [error]: Scrip 57 Prepare failed: Global symbol
"$Ticket" requires explicit package name at (eval 2195) line 6.
Global symbol “$Transaction” requires explicit package name at (eval 2195)
line 18.
Global symbol “$Transaction” requires explicit package name at (eval 2195)
line 24.
syntax error at (eval 2195) line 24, near “->SetOwner[”
(/opt/rt3/lib/RT/Action/UserDefined.pm:65)

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];
$Transaction->TicketObj->SetOwner($new_owner);
$isSet = 1;
}
}

if (!($isSet)) {
$Transaction->TicketObj->SetOwner[int(rand($#owners))];
}

$self->TicketObj->SetOwner

Hey, that was it. But I guess now I’m missing one other piece of data -
currentuser?

I promise after I get this resolved, I’ll sign up for the one day RT
developer training session!

[Tue Dec 28 23:30:34 2004] [error]: Scrip 57 Prepare failed: No currentuser
at /opt/rt3/lib/RT/Base.pm line 123
RT::Base::loc(‘RT::System=HASH(0x9d9940c)’, ‘Queue’) called at
/opt/rt3/lib/RT/Base.pm line 118
RT::Base::loc(‘RT::Tickets=HASH(0x9d3cd78)’, ‘Queue’) called at
/opt/rt3/lib/RT/Tickets_Overlay.pm line 1047
RT::tickets::LimitQueue(‘RT::Tickets=HASH(0x9d3cd78)’, ‘VALUE’, ‘ICI
Internal’) called at (eval 2529) line 5
eval '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 => $self->TicketObj->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];
$self->TicketObj->SetOwner($new_owner);
$isSet = 1;
}
}

if (!($isSet)) {
my $randOwner = int(rand($#owners));
$randOwner = $owners[$randOwner];
$self->TicketObj->SetOwner($randOwner);
}

Change RT::System to RT::SystemUserOn Tue, Dec 28, 2004 at 03:36:33PM -0800, matthew zeier wrote:

$self->TicketObj->SetOwner

Hey, that was it. But I guess now I’m missing one other piece of data -
currentuser?

I promise after I get this resolved, I’ll sign up for the one day RT
developer training session!

[Tue Dec 28 23:30:34 2004] [error]: Scrip 57 Prepare failed: No currentuser
at /opt/rt3/lib/RT/Base.pm line 123
RT::Base::loc(‘RT::System=HASH(0x9d9940c)’, ‘Queue’) called at
/opt/rt3/lib/RT/Base.pm line 118
RT::Base::loc(‘RT::Tickets=HASH(0x9d3cd78)’, ‘Queue’) called at
/opt/rt3/lib/RT/Tickets_Overlay.pm line 1047
RT::tickets::LimitQueue(‘RT::Tickets=HASH(0x9d3cd78)’, ‘VALUE’, ‘ICI
Internal’) called at (eval 2529) line 5
eval '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 => $self->TicketObj->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];
$self->TicketObj->SetOwner($new_owner);
$isSet = 1;
}
}

if (!($isSet)) {
my $randOwner = int(rand($#owners));
$randOwner = $owners[$randOwner];
$self->TicketObj->SetOwner($randOwner);
}

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@dougware.net
K1DUG
(919) 201-8750

foreach $i ( @owners) {
if ($owners[$i] == $last_owner) {
$new_owner = $owners[$i+1];

The above makes no sense, likely written by someone who doesn’t know
Perl. For loops don’t loop over array indexes when just given an array,
they loop over the array items. Try:

foreach $id (@owner) {
if ($id == $last_owner) {
$new_owner = $id;

I apologize, but Perl isn’t my strong suit. :smiley:

Changing those three lines still compiles and updates the scrip, but it
doesn’t do anything and never assigns the ticket to anyone now.

Doug

Sincerely,
Doug Eubanks
admin@dougware.net
K1DUG
(919) 201-8750On Fri, Apr 12, 2013 at 1:18 PM, Thomas Sibley trs@bestpractical.comwrote:

On 04/12/2013 08:20 AM, Doug Eubanks wrote:

foreach $i ( @owners) {
if ($owners[$i] == $last_owner) {
$new_owner = $owners[$i+1];

The above makes no sense, likely written by someone who doesn’t know
Perl. For loops don’t loop over array indexes when just given an array,
they loop over the array items. Try:

foreach $id (@owner) {
if ($id == $last_owner) {
$new_owner = $id;

$self->TicketObj->SetOwner($new_owner);
$isSet = 1;

}
}

I apologize, but Perl isn’t my strong suit. :smiley:

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 apologize, but Perl isn’t my strong suit. :smiley:

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

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?

I apologize, but Perl isn’t my strong suit. :smiley:

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
);

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;

some change in the cleanup code

if you want to disable it, just uncomment the following line

return 1;

get out if ticket has a owner

return 1 unless $self->TicketObj->Owner == $RT::Nobody->id;

get the user list from the file

this file has the list of users who will be assigned as owner in

round-robin

you could have another logic external that could update this file to get

the

generate the list of owners

my $file = “/var/tmp/ownerlist”;

return 1 unless open(my $fh, ‘<’, $file);
my @owners = <$fh>;
return 1 unless close $fh;

sanitizing the entries - accounts should be all alphanumerics

foreach my $line (@owners) {
$line =~ tr/A-Za-z0-9//cd;
}

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];

Some debug option when uncommented

$RT::Logger->info("AUTOASSIGN: DEBUG “. $self->TicketObj->id .” to user

". $owner );

$RT::Logger->info("AUTOASSIGN: DEBUG Total number of owners ".

scalar(@owners) );

uncomment this if you want to run in dry run mode

return 1;

set the owner

$RT::Logger->info("AUTOASSIGN: “. $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?

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?

get the user list from the file

this file has the list of users who will be assigned as owner in

round-robin

you could have another logic external that could update this file to

get the

generate the list of owners

my $file = “/var/tmp/ownerlist”;

return 1 unless open(my $fh, ‘<’, $file);
my @owners = <$fh>;
return 1 unless close $fh;

I think a better solution for the owners list would be to create a group
in RT, assign the needed users to the group and then load the possible
owner from that group. With this, you can change the owners list from
the RT Webinterface.

Script code would be something like this:

my @owners;
my $users = RT::Users->new(RT->SystemUser);
$users->MemberOfGroup();
while( my $user = $users->Next ) {
push @owners, $user->Name;
}

Chris

Am 22.10.2015 um 22:21 schrieb Asif Iqbal:

get the user list from the file

this file has the list of users who will be assigned as owner in

round-robin

you could have another logic external that could update this file to

get the

generate the list of owners

my $file = “/var/tmp/ownerlist”;

return 1 unless open(my $fh, ‘<’, $file);
my @owners = <$fh>;
return 1 unless close $fh;

I think a better solution for the owners list would be to create a group
in RT, assign the needed users to the group and then load the possible
owner from that group. With this, you can change the owners list from
the RT Webinterface.

Script code would be something like this:

my @owners;
my $users = RT::Users->new(RT->SystemUser);
$users->MemberOfGroup();
while( my $user = $users->Next ) {
push @owners, $user->Name;
}

I agree, this is cleaner. Although, I picked the external file since I am
looking
for a way to update that with users who are not in vacation.

Chris

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?