Queue wise Default Ticket Owner

Want to assign a default technician to tickets in a specific queue however facing some challenges…

Does anyone on the forum have a solution for this…?

You can take a look at this extension:

Here’s my script. Don’t know what’s going wrong…

get actor ID

my $Actor = $self->TransactionObj->Creator;

create a new user object

my $NewOwner = RT::User->new($RT::SystemUser);

and load the user into that object

$NewOwner->Load(‘darshit.kothari@ahwspl.com’);

if actor is RT_SystemUser then get out of here

return 1 if $Actor == $RT::SystemUser->id;

prevents a ticket being assigned to an unprivileged user, comment out if you want this

return 1 unless $self->TransactionObj->CreatorObj->Privileged;

get out unless ticket owner is nobody

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

ok, try to change owner

$RT::Logger->info(“Auto assign ticket #”. $self->TicketObj->id ." to user #". $NewOwner->id );
my ($status, $msg) = $self->TicketObj->_Set(Field => ‘Owner’, Value => $NewOwner->id, RecordTransaction => 0);
unless( $status ) {
$RT::Logger->error( “Impossible to assign the ticket to ‘nandlal.singh@ahwspl.com’: $msg” );
return undef;
}
return 1;

What’s the scrip doing anything in the log?

Is this a script (with a t) or a scrip? In other words is it something you’ve written that you run from the comand line, or a scrip that runs when a ticket is created? If the latter, which bits are the preparation code (which should return 1 if you want to do the action) and which bits are the actual action (ie setting the owner of the ticket)? You seem to return 1 no matter if you try to make the change or not?

Thanks knation and jimil,

Got to know where the script went wrong and was able to fix it to get the requirement fulfilled…

One concern that I have is that I have Enabled this script for a specific queue but is visible to Queue configurations of other queues as well… Any way I can hide that from the Scripts section of other queues…?

Thanks & Regards,
Darsh

As in you want to hide the scrip from the Admin->Queues->Scrip page?

want to hide unwanted scrips from the admin → queue → scrips section

I think to hide it you’d need something like the JS code to hide the table row

is there a way I can use a single scrip for defaulting users based on the queue name

the scrip that I have written so far to set actor is as below:

if ($self->$TicketObj->QueueObj->Name eq “queue-one”) {
my $User = new RT::User($RT::SystemUser);
$User->LoadByEmail(‘userone@abc.com’);
my $Actor = $User->id;
}
elsif ($self->$TicketObj->QueueObj->Name eq “queue-two”) {
my $User = new RT::User($RT::SystemUser);
$User->LoadByEmail(‘usertwo@abc.com’);
my $Actor = $User->id;
}
return 1 if $Actor == $RT::SystemUser->id;
return 1 unless $self->TransactionObj->CreatorObj->Privileged;
return 1 unless $self->TicketObj->Owner == $RT::Nobody->id;

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

If you create groups that you can programmatically work out the name of from the queue name, you could put the users you want to use for each queue in the appropriate group, and then look that group up from the queue that the scrip is being run for.

For example code above, you could create groups called queue-one default technician and queue-two default technician. Then assign userone@abc.com to queue-one default technician and usertwo@abc.com to queue-two default technician. Then modify your scrip to look up membership of a group called <queue name> default technician and set the owner to the member(s) of that group.

This has the advantage that its scalable. You can easily add new queues/groups/technicians without touching the scrip. And you could also switch technicians (eg to cover holidays or people leaving/joinging) just by group membership changes. And that membership management could be delegated via ACLs to managers rather than having RT admins diddling with the scrip code.

I am actually a newbie and I’m afraid I dont have the expertise to write the scrip needed to achieve the desired result…
can you please help me with this…?