Automatically Change Requestor and Put in Certain Queue

I’m looking to create a script that deletes the requestor/watcher (in this case helpdesk@myuniv.edu) and replaces it with whatever dynamic address is in the email portion within the body of the email. Then I’d like to put the ticket into a different queue (Named: CRM Helpdesk) to keep things organized.

Any suggestions or pointers would be awesome and much appreciated.


The email comes in to RT from helpdesk@myuniv.edu:

This is an automated email generated from our CRM.
The student requiring support is as follows:

Name:   Joe Student
Student ID:   Z10348294903 
Email:   joe.student@myuniv.edu

The submitter and comments are detailed below:

 I need some computer help!!! Help me now! Right now!

Note: For additional questions, please contact your CRM Admin.

1 Like

I’m guessing you’ll need an OnCreate scrip (assuming this is happening when new tickets are being opened) that has a user defined perl template attached. In this template you’ll need to:

  • Check if the ticket has come from helpdesk@myuniv.edu (return immediately otherwise).
  • Extract the student email from the transaction contents (which you can get using $Ticket->Transactions->First->Content), probably using a regex. Put this into a variable such as $studentEmail.
  • Once you have the new requestor email you’ll have to call $Ticket->DeleteWatcher(Email => 'helpdesk@myuniv.edu', Type => 'Requestor'); to remove the helpdesk as the requestor.
  • Lastly add the new student as the requestor using something like $Ticket->AddWatcher(Email => $studentEmail, Type => 'Requestor');.

Is there any way to set the “Reply-to” header to joe.student@myuniv.edu before sending the mail from your CRM? This will make it much easier.

@GreenJimll – Excellent suggestions! We will look into that. Once I do a little more work on this, I’ll post back any questions and the results.

@sollericos – Unfortunately no. If we could, we’d have it do that and alleviate a lot of this work.

Oh, just noticed I missed off the last bit of your request: changing the queue. You probably want something like this:

my $crmQueue = new RT::Queue( $RT::SystemUser );
$crmQueue->Load('CRM Helpdesk');
$Ticket->SetQueue($crmQueue->id);

One side effect of this is that it will generate a new “On Queue Change” transaction, and any scrips associated with that will be queued to fire off. This is probably what you want (so that notifications, etc get sent out), but just in case you don’t for some reason, you can use this to change the queue without a transaction being generated:

my $crmQueue = new RT::Queue( $RT::SystemUser );
$crmQueue->Load('CRM Helpdesk');
$Ticket->_Set(Field => 'Queue', Value => $crmQueue->id, RecordTransaction => 0);

Thanks @GreenJimll – I’ll be working on this more this week. I’ll give the suggestions a shot.

@GreenJimll – Finally had time to work thru this… and got it tailored to how we want it to work…

Thank you for all the help as well as everyone else who chimed in and offered assistance and guidance.

Happy holidays! :wave:


Custom condition: return 1;

Custom action preparation code: my $T_Obj = $self->TicketObj;
my $subject = $T_Obj->Subject;

if ($subject => ‘CRM: Reported Alert’) {

my $content = $T_Obj->Transactions->First->Content;

my ($email) = $content =~ /Email: (.*)/;
$self->TicketObj->DeleteWatcher(
Type => ‘Requestor’,
Email => ‘helpdesk@myuniv.edu’
);
$self->TicketObj->AddWatcher(
Type => ‘Requestor’,
Email => $email
);
return 1;
} else {
return 0;
}

Custom action commit code: return 1;

1 Like