I'd like to know if there is a way to set multiple responsible agents to a ticket, so that they may follow all the ticket actions, or to add them automatically to the watchlist. Is this possible?

Moderator: crythias
Code: Select all
# --
# Kernel/System/Ticket/Event/TicketCreateSuscribe.pm - test event module
# Copyright (C) 2001-2011 xxx, http://otrs.org/
# --
# $Id: Test.pm,v 1.12 2011-11-25 10:14:18 mg 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::TicketCreateSuscribe;
use strict;
use warnings;
use vars qw($VERSION);
$VERSION = qw($Revision: 1.12 $) [1];
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
# get needed objects
for (qw(ConfigObject TicketObject LogObject UserObject CustomerUserObject SendmailObject)) {
$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;
}
}
if ( $Param{Event} eq 'TicketCreate' ) {
my %Ticket = $Self->{TicketObject}->TicketGet(
TicketID => $Param{Data}->{TicketID},
DynamicFields => 0,
);
if ( $Ticket{Type} eq 'DEMANDE DE SERVICE' ) {
#we start doing stuff
# trigger event
$Self->{TicketObject}->TicketWatchSubscribe(
TicketID => $Param{TicketID},
WatchUserID => $Param{UserID},
UserID => $Param{UserID},
);
# add history
$Self->HistoryAdd(
TicketID => $Param{TicketID},
CreateUserID => $Param{UserID},
HistoryType => 'Subscription to watchlist',
Name => "\%\%$User{UserFirstname} $User{UserLastname} ($User{UserLogin})",
);
return 1;
}
}
1;
Code: Select all
$Self->{'Ticket::EventModulePost'}->{'111-TicketCreateSuscribe'} = {
Module => 'Kernel::System::Ticket::Event::TicketCreateSuscribe',
Event => 'TicketCreate',
};
Thank you very much i'll check it out, i corrected the postreneeb wrote:Please use the$SELF -> $SelfCode: Select all
-Tags... Your config should look like [code]$Self->{'Ticket::EventModulePost'}->{'111-TicketCreateSuscribe'} = { Module => 'Kernel::System::Ticket::Event::TicketCreateSuscribe', Event => 'TicketCreate', };
module -> Module
added: Event
I didn't check the Perl module...
nothing! I tried correcting the module so that it could get a certain ticket type and then suscribe the user to the watcher list... but it still does not work...reneeb wrote:Any messages in the log files?
Code: Select all
# --
# Kernel/System/Ticket/Event/TicketCreateSuscribe - test event module
package Kernel::System::Ticket::Event::TicketCreateSuscribe;
use strict;
use warnings;
use vars qw($VERSION);
$VERSION = qw($Revision: 1.12 $) [1];
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
# get needed objects
for (qw(ConfigObject TicketObject LogObject UserObject CustomerUserObject SendmailObject TypeID UserID)) {
$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;
}
}
if ( $Param{Event} eq 'TicketCreate' ) {
my %Ticket = $Self->{TicketObject}->TicketGet(
TicketID => $Param{Data}->{TicketID},
DynamicFields => 0,
);
if ( $Param{TypeID} eq '15') {
#we start doing stuff
# trigger event
$Self->{TicketObject}->TicketWatchSubscribe(
TicketID => $Param{TicketID},
WatchUserID => $Param{UserID},
UserID => $Param{UserID},
);
# add history
$Self->HistoryAdd(
TicketID => $Param{TicketID},
CreateUserID => $Param{UserID},
HistoryType => 'Subscription to watchlist',
Name => "\%\%$User{UserFirstname} $User{UserLastname} ($User{UserLogin})",
);
}
}
return 1;
}
1;