Calling another perl script once ticket is saved/updated

Hi,

I’m new to RT, so please don’t flame me for asking a newbie question :
)

Here’s the problem:

I’ve been asked to modify RT so that every time a ticket is created /
modified, I need to take that ticket content and save it in another CRM
system that my company uses as well; I’ve already finished writing a
separate script which expects a ticket_id to be passed to it and this
script does the rest of the work; all that’s left for me to do is to
insert a call to that script into the RT’s source code wherever tickets
are saved into the mysql database. I’ve been trying to find out which
source code file is responsible for inserting the data into the
associated mysql database, but, for the life of me, i cant seem to
figure this out… help ! : )

At Friday 10/7/2005 01:24 PM, Vipin Hegde wrote:

Here’s the problem:
I’ve been asked to modify RT so that every time a ticket is created /
modified, I need to take that ticket content and save it in another CRM
system that my company uses as well; I’ve already finished writing a
separate script which expects a ticket_id to be passed to it and this
script does the rest of the work; all that’s left for me to do is to
insert a call to that script into the RT’s source code wherever tickets
are saved into the mysql database. I’ve been trying to find out which
source code file is responsible for inserting the data into the
associated mysql database, but, for the life of me, i cant seem to figure
this out… help ! : )

You can’t make a direct call to a perl script from RT (as far as I know).
Here are a couple of ideas for doing what you want.

  • Create a custom action containing the code you’ve written and create
    scrips to invoke the action whenever a ticket is created or modified. You
    may also need a custom scrip condition to detect the ticket-modified event.

  • Use RT scrips to send email to your perl script whenever a ticket is
    created or modified. Again, you may also need a custom scrip condition to
    detect the ticket-modified event.

The wiki is a great resource for learning about scrips, actions, conditions
and all things RT.

Steve

This should be pretty easy. Just create a new Scrip:

Description: whatever
Condition: On Create
Action: UserDefined
Template: Global template: None
Stage: TransactionCreate (or Batch)

Then in the Custom Action Prep just:

Path/to/script.pl $self->TicketObj->Id;

As a part of our eval I set up a separate script to determine a contact
if the CustomField “Hostname” was set:

Action Prep Code:

my $ticket = $self->TicketObj;
if ($ticket->CustomFieldValues(“Hostname”)->Next == undef){
return(undef);
}
if ($ticket->CustomFieldValues(“Contact”)->Next != undef){
return(undef);
}
my $hostname = $ticket->CustomFieldValues(“Hostname”)->Next->Content;
$self->{‘custvalue’} = /data/rt34/bin/oncall $hostname;
$self->{‘custfield’} = $ticket->QueueObj->CustomField(“Contact”);
return (1);

Joby Walker
ITI SSG, University of Washington

Vipin Hegde wrote: