Round-robin auto assignment?

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.

anyone added a logic to not auto assign the ticket if it is created during
holiday or weekends?

We are using Lifecycles to implement Due date based on business hours using
the SLA extension. But not sure how auto assign can take advantage of that.

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?

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?

anyone added a logic to not auto assign the ticket if it is created
during holiday or weekends?

We are using Lifecycles to implement Due date based on business hours
using the SLA extension. But not sure how auto assign can take advantage
of that.

If you have rt-extension-sla installed, then you can create a
Business::Hours [1] object in a RT scrip with:
my $bh = RT::Extension::SLA->BusinessHours;

If you don’t have holidays in your sla config
(RT::ServiceBusinessHours), then you can feed the $bh from above within
you scrip.
We use Date::Holidays::DE [2] for this, which have the german holidays,
ans is also available for other countries.

Then you can check if you are within business hours with:
if ($bh->first_after(time()) == time()) {
# within business hours
} else {
# not within business hours
}

Chris

[1] Business::Hours - Calculate business hours in a time period - metacpan.org
[2] Date::Holidays::DE - Determine German holidays - metacpan.org

I can’t get your scrip to compile.

However I got the initial scrip to compile in this thread:

my @owners = qw( 11279 32533 30745 7609 22201 4977 33467 17869 22203 162 );
 # need to grab id from Users table
push(@owners, @owners);
my $tickets = RT::Tickets->new($RT::SystemUser);
$tickets->LimitQueue(VALUE => 'General'); # 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 $id (@owner) { 
if ($id == $last_owner) { 
$new_owner = $id; 
$self->TicketObj->SetOwner($new_owner);
$isSet = 1;
}
}
if (!($isSet)) {
my $randOwner = int(rand($22));
$randOwner = $owners[$randOwner];
$self->TicketObj->SetOwner($randOwner);
}

It compiles just fine, but I get the following error in my log:

Scrip 17 Prepare failed: Global symbol "$i" requires explicit package name at (eval 789) line 1.#012Global symbol "@owners" requires explicit package name at (eval 789) line 1.#012Global symbol "@owners" requires explicit package name at (eval 789) line 2.#012Global symbol "$i" requires explicit package name at (eval 789) line 2.#012Global symbol "$last_owner" requires explicit package name at (eval 789) line 2.#012Global symbol "$id" requires explicit package name at (eval 789) line 14.#012Global symbol "@owner" requires explicit package name at (eval 789) line 14.#012Global symbol "$id" requires explicit package name at (eval 789) line 15.#012Global symbol "$id" requires explicit package name at (eval 789) line 16.

Scrip 17 Commit failed: Global symbol "$id" requires explicit package name at (eval 615) line 12.#012Global symbol "@owner" requires explicit package name at (eval 615) line 12.#012Global symbol "$id" requires explicit package name at (eval 615) line 13.#012Global symbol "$id" requires explicit package name at (eval 615) line 14.

Can anyone understand what the issue is?

I’m running PERL 5 version 14 on RT 4.2