RT Essentials by Jesse Vincent; Robert Spier; Dave Rolsky; Darren Chamberlain; Richard Foley

RT Essentials by Jesse Vincent; Robert Spier; Dave Rolsky; Darren Chamberlain; Richard Foley

Author:Jesse Vincent; Robert Spier; Dave Rolsky; Darren Chamberlain; Richard Foley
Language: eng
Format: mobi
Tags: Reference:Computers
ISBN: 6125559912
Publisher: O'Reilly Media
Published: 2008-12-17T10:00:00+00:00


CleanEnv();

RT::LoadConfig();

RT::Init();

my $user = GetCurrentUser();

unless( $user->Id ) {

print "No RT user found. Please consult your RT administrator.\n";

exit 1;

}

my $sc = RT::ScripCondition->new($user);

$sc->Create( Name => 'After Hours Emergency',

Description => 'An emergency ticket is created after hours',

ExecModule => 'OnAfterHoursEmergency',

ApplicableTransTypes => 'Create',

);

Note that ApplicableTransTypes field is set to Create, ensuring that this condition is checked only when a new ticket is created. We could have done this in the condition module's IsApplicable() method, but this is more efficient.

To create a new scrip for this condition, we would pick After Hours Emergency from the condition drop down in the new scrip form. The action will be Notify Other Recipients. The actual recipients will be picked up from the template. For the template, we use the one we just created.

If we had different pager numbers for different queues, we could create several templates. Then we would set up scrips for each queue, all using the same condition and action, each with a different template.

Using TransactionBatch

Earlier, we talked about the two stages where scrips could run, TransactionCreate and TransactionBatch. The latter stage needs to be enabled in your configuration before it is available.

This might be needed, for example, if you wanted to send an email whenever any of the custom fields for a ticket were updated. Because of the way custom fields work, each change to a custom field is a separate transaction. If a ticket might have five custom fields, we do not want to send five emails every time that ticket is updated!

We can use the TransactionBatch stage to look at all of the transactions at once. Here's an example of a simple template that would run in the TransactionBatch stage:

{

my @batch = @{ $Ticket->TransactionBatch };



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.