Request Tracker: Automatically Set Ticket Owner to Specific User

Published 2019-10-28 on Matthew's Blog

Request Tracker is an insanely powerful ticketing system. I started using RT about 6 months ago, and I’ve been absolutely enjoying every hour of it. About 2 months ago, I used a guide on the RT Wiki titled AutoSetOwner to automatically set every new ticket’s owner to myself, on my personal hosted instance of RT. It works great!

Now, since I’m more or less the only IT person at this company, it’s safe to assume that any ticket in the IT Projects, or certain other queues should belong to me. So I adapted the AutoSetOwner scrip to automatically set the owner of a new ticket to myself, on certain queues. I have to admit, since I don’t know Perl hardly at all, it took a little trial and error to get this right, fortunately RT’s logs came in useful and I now have a working scrip!

The process is very similar to AutoSetOwner by Nicolas C. I’ve simply added a few lines to get the ID of the user whom I want to own these new tickets.

Description Set IT tickets to IT manager
Condition On Create
Action User Defined
Template Blank

Custom action preparation code:

return 1;

Custom action commit code:

# get actor ID
my $Actor = $self->TransactionObj->Creator;

# get mjorgensen's id
# create a new user object
my $NewOwner = RT::User->new($RT::SystemUser);

# and load the user into that object
$NewOwner->Load('mjorgensen');

# 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 'mjorgensen': $msg" );
return undef;
}
return 1;

Be sure the change mjorgensen to what your user’s name is. Save changes, assign this scrip to each desired queue, and you’re all set!

Have a comment on one of my posts? Start a discussion in my public inbox by sending an email to ~mjorgensen/public-inbox@lists.sr.ht [mailing list ettiquette]


Articles from blogs I follow around the net

Why you shouldn't start a newsletter

It seems like there’s a new trend popping up: Newsletters and paid newsletters. I prefer to read content using a news reader, with which I can subscribe to countless RSS (or JSON) feeds. I can also decide when to consume new content and am not bothered wit…

via Posts on jlelse's Blog November 2, 2019

An old-school shell hack on a line printer

It’s been too long since I last did a good hack, for no practical reason other than great hack value. In my case, these often amount to a nostalgia for an age of computing I wasn’t present for. In a recent bid to capture more of this nostalgia, I recently pi…

via Drew DeVault's Blog October 30, 2019

Hello.

via gokigen October 16, 2019

Generated by openring


Recent Posts

Hi there!

I'm a systems administrator, front-end and back-end developer, and an IT guru in Minneapolis, MN. It’s nice to meet you.