I'm trying to make my own Ticket Event action, based on crythias' very helpful tutorial http://forums.otrs.org/viewtopic.php?f=60&t=10090.
What I'm trying to do is quite simple (I think...) : I just want the Ticket SLA to be automatically updated as soon as the Ticket Priority has been set for the first time or changed (in other words : link SLA to priority).
In my current code, which is only a test, I'm trying to set the Ticket SLA to the value "Platinium" as soon as the Ticket Priority is modified.
Here is the xml file code (name: PrioritySLAUpdate.xml, placed in Kernel\Config\Files directory):
Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<otrs_config version="1.0" init="Changes">
<ConfigItem Name="Ticket::EventModulePost###PrioritySLAUpdate" Required="0" Valid="1">
<Description Lang="en">Update SLA based on ticket Priority</Description>
<Group>PrioritySLAUpdate</Group>
<SubGroup>EventModule</SubGroup>
<Setting>
<Hash>
<Item Key="Module">Kernel::System::Ticket::Event::PrioritySLAUpdate</Item>
<Item Key="Event">TicketPriorityUpdate</Item>
</Hash>
</Setting>
</ConfigItem>
</otrs_config>
Code: Select all
# --
# Kernel/System/Ticket/Event/PrioritySLAUpdate.pm - unlock ticket
# Copyright (C) 2001-2010 xxx, http://otrs.org/
# --
# $Id: PrioritySLAUpdate.pm,v 1.0 2010/05/19 07:08:18 mb Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --
package Kernel::System::Ticket::Event::PrioritySLAUpdate;
use strict;
use warnings;
use vars qw($VERSION);
$VERSION = qw($Revision: 1.1 $) [1];
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
# get needed objects
for (
qw(
ConfigObject CustomerGroupObject CustomerUserObject DBObject EncodeObject GroupObject
HTMLUtilsObject LinkObject LockObject LogObject LoopProtectionObject MainObject
PriorityObject QueueObject SendmailObject ServiceObject SLAObject StateObject
TicketObject TimeObject TypeObject UserObject ValidObject
)
)
{
$Self->{$_} = $Param{$_} || die "Got no $_!";
}
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
# check needed stuff
for (qw(Data Event Config)) {
if ( !$Param{$_} ) {
$Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
return;
}
}
for (qw(TicketID)) {
if ( !$Param{Data}->{$_} ) {
$Self->{LogObject}->Log( Priority => 'error', Message => "Need $_ in Data!" );
return;
}
}
# update SLA
$Self->{TicketObject}->TicketSLASet(
TicketID => $Param{Data}->{TicketID},
UserID => $Param{UserID},
SLA => 'Platinium',
);
return 1;
}
1;
Could you please help me ?