How to Chnage Ticket Status when ticket is Locked
Moderator: crythias
-
- Znuny newbie
- Posts: 12
- Joined: 21 Feb 2011, 08:19
- Znuny Version: otrs-2.4.7-01
How to Chnage Ticket Status when ticket is Locked
Dear All,
I am planning to use OTRS as my ticket management system. I have configured most of the functionality as per my requirement. Only thing I am struggling now is , I want to change the status of the ticket to "Work In Progress" whenever an Agent Locks it. It should happen automatically i;e the Lock event should change the status to work in progress. I have already created one status as Work In Progress , but I don't know how to integrate with Lock event. Is it possible guys???? If yes please help me or guide me how to go about it.
All the reply will be appreciated
Thanks in advance.
I am planning to use OTRS as my ticket management system. I have configured most of the functionality as per my requirement. Only thing I am struggling now is , I want to change the status of the ticket to "Work In Progress" whenever an Agent Locks it. It should happen automatically i;e the Lock event should change the status to work in progress. I have already created one status as Work In Progress , but I don't know how to integrate with Lock event. Is it possible guys???? If yes please help me or guide me how to go about it.
All the reply will be appreciated
Thanks in advance.
-
- Znuny expert
- Posts: 241
- Joined: 06 Feb 2009, 11:15
- Znuny Version: 3.0.x
- Company: Perl-Services.de
- Contact:
Re: How to Chnage Ticket Status when ticket is Locked
You need a module for that event:
And add this in Kernel/Config.pm:
Code: Select all
# --
# Kernel/System/Ticket/Event/SetStateOnLock.pm - a event module
# Copyright (C) 2010-2011 perl-services.de, http://perl-services.de/
# --
# $Id: SetStateOnLock.pm,v 1.5 2011/05/31 13:28:21 rb 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::SetStateOnLock;
use strict;
use warnings;
use vars qw($VERSION);
$VERSION = qw($Revision: 1.5 $) [1];
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
# get needed objects
for my $Needed (
qw(DBObject ConfigObject TicketObject LogObject QueueObject MainObject EncodeObject TimeObject)
)
{
$Self->{$Needed} = $Param{$Needed} || die "Got no $Needed!";
}
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
# check needed stuff
for (qw(Event Data Config UserID)) {
if ( !$Param{$_} ) {
$Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
return;
}
}
return 1 if $Param{Event} ne 'TicketQueueUpdate'; # we just want to act when the ticket is moved
for (qw(TicketID)) {
if ( !$Param{Data}->{$_} ) {
$Self->{LogObject}->Log( Priority => 'error', Message => "Need $_ in Data!" );
return;
}
}
my $TicketID = $Param{TicketID};
$Self->{TicketObject}->TicketStateSet(
TicketID => $TicketID,
UserID => 1,
State => 'Work In Progress',
);
return 1;
}
1;
Code: Select all
$Self->{'Ticket::EventModulePost'}->{'110-SetStateOnLock'} = {
'Event' => '(TicketLockUpdate)', # Here you register the events you want to listen to
'Module' => 'Kernel::System::Ticket::Event::SetStateOnLock', # the module that is called for those events
};
Need a Perl/OTRS developer? You can contact me at info@perl-services.de
-
- Znuny newbie
- Posts: 12
- Joined: 21 Feb 2011, 08:19
- Znuny Version: otrs-2.4.7-01
Re: How to Chnage Ticket Status when ticket is Locked
Dear Renee,
Thanks a lot for your quick reply. I have tried to implement the module but I am unable to see the result. The state is still new at customer end even though the ticket is locked by the agent. But according to the code customer should see the state as work in progress..
Thanks a lot for your quick reply. I have tried to implement the module but I am unable to see the result. The state is still new at customer end even though the ticket is locked by the agent. But according to the code customer should see the state as work in progress..
-
- Znuny expert
- Posts: 241
- Joined: 06 Feb 2009, 11:15
- Znuny Version: 3.0.x
- Company: Perl-Services.de
- Contact:
Re: How to Chnage Ticket Status when ticket is Locked
Copy'n'paste error:
has to substituted with
Maybe an other check has to be added, too: Check if ticket is locked or unlocked...
Code: Select all
return 1 if $Param{Event} ne 'TicketQueueUpdate'; # we just want to act when the ticket is moved
Code: Select all
return 1 if $Param{Event} ne 'TicketLockUpdate';
Need a Perl/OTRS developer? You can contact me at info@perl-services.de
-
- Znuny newbie
- Posts: 12
- Joined: 21 Feb 2011, 08:19
- Znuny Version: otrs-2.4.7-01
Re: How to Chnage Ticket Status when ticket is Locked
Really appriciate your effort, but there is no change in the state even after I made the code changes as suggested by you. It's really defficult for me to track the error as I am completely new to perl script. Please suggest how to trace the error and proceed.
I have checket thet the ticket is locked.
please find the attached to have a beetter understanding of the issue.
I have checket thet the ticket is locked.
please find the attached to have a beetter understanding of the issue.
You do not have the required permissions to view the files attached to this post.
-
- Znuny expert
- Posts: 241
- Joined: 06 Feb 2009, 11:15
- Znuny Version: 3.0.x
- Company: Perl-Services.de
- Contact:
Re: How to Chnage Ticket Status when ticket is Locked
Ok, use this code:
Then do the following:
If the result is "Syntax ok", the module should be triggered.
Then you should tail the log (tail -f /path/to/otrs.log)
Code: Select all
# --
# Kernel/System/Ticket/Event/SetStateOnLock.pm - a event module
# Copyright (C) 2010-2011 perl-services.de, http://perl-services.de/
# --
# $Id: SetStateOnLock.pm,v 1.5 2011/05/31 13:28:21 rb 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::SetStateOnLock;
use strict;
use warnings;
use vars qw($VERSION);
$VERSION = qw($Revision: 1.5 $) [1];
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
# get needed objects
for my $Needed (
qw(DBObject ConfigObject TicketObject LogObject QueueObject MainObject EncodeObject TimeObject)
)
{
$Self->{$Needed} = $Param{$Needed} || die "Got no $Needed!";
}
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
$Self->{LogObject}->Log(
Priority => 'error',
Message => 'Run SetStateOnLock',
);
# check needed stuff
for (qw(Event Data Config UserID)) {
if ( !$Param{$_} ) {
$Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
return;
}
}
return 1 if $Param{Event} ne 'TicketLockUpdate';
my $TicketID = $Param{TicketID};
$Self->{LogObject}->Log(
Priority => 'error',
Message => 'SetStateOnLock - Ticket: ' . $TicketID,
);
my %TicketData = $Self->{TicketObject}->TicketGet(
TicketID => $TicketID,
);
$Self->{LogObject}->Log(
Priority => 'error',
Message => 'Run SetStateOnLock - new Lockstate: ' . $TicketData{Lock},
);
return 1 if $TicketData{Lock} ne 'lock'; # set new state only if ticket is locked now
$Self->{TicketObject}->StateSet( # StateSet is 2.x method, in 3.x it is TicketStateSet
TicketID => $TicketID,
UserID => 1,
State => 'Work In Progress',
);
return 1;
}
1;
Code: Select all
cd /opt/otrs/
perl -IKernel/cpan-lib/ -cw Kernel/System/Ticket/Event/SetStateOnLock.pm
Then you should tail the log (tail -f /path/to/otrs.log)
Need a Perl/OTRS developer? You can contact me at info@perl-services.de
-
- Znuny newbie
- Posts: 12
- Joined: 21 Feb 2011, 08:19
- Znuny Version: otrs-2.4.7-01
Re: How to Chnage Ticket Status when ticket is Locked
Yes have made changes and the code gives O/P Syntax is Ok
but the syslog message i;e the /var/log/message gives O/P as
Code: Select all
perl -IKernel/cpan-lib/ -cw Kernel/System/Ticket/Event/SetStateOnLock.pm
but the syslog message i;e the /var/log/message gives O/P as
Code: Select all
Aug 10 14:33:21 ************** OTRS-CGI-10[11484]: [Error][Kernel::System::Ticket::Event::SetStateOnLock::Run][Line:41]: Run SetStateOnLock
Aug 10 14:33:21 ************** OTRS-CGI-10[11484]: [Error][Kernel::System::Ticket::Event::SetStateOnLock::Run][Line:49]: Need Data!
Aug 10 14:33:26 ************** OTRS-CGI-10[11516]: [Error][Kernel::System::Ticket::Event::SetStateOnLock::Run][Line:41]: Run SetStateOnLock
Aug 10 14:33:26 ************** OTRS-CGI-10[11516]: [Error][Kernel::System::Ticket::Event::SetStateOnLock::Run][Line:49]: Need Data!
-
- Znuny expert
- Posts: 241
- Joined: 06 Feb 2009, 11:15
- Znuny Version: 3.0.x
- Company: Perl-Services.de
- Contact:
Re: How to Chnage Ticket Status when ticket is Locked
Replace with and try it again...
Code: Select all
for (qw(Event Data Config UserID)) {
Code: Select all
for (qw(Event UserID TicketID)) {
Need a Perl/OTRS developer? You can contact me at info@perl-services.de
-
- Znuny newbie
- Posts: 12
- Joined: 21 Feb 2011, 08:19
- Znuny Version: otrs-2.4.7-01
Re: How to Chnage Ticket Status when ticket is Locked
Thanks a lot Renee... Thant worked.... Thanks for the great support and guidance...
-
- Znuny newbie
- Posts: 12
- Joined: 21 Feb 2011, 08:19
- Znuny Version: otrs-2.4.7-01
Re: How to Chnage Ticket Status when ticket is Locked
Dear Renne,
Now If I would like to achieve the objective of " if ticket state is closed then it should automatically get Unlocked" . Where do I need to modify.. in ForceState.pm or in ForceUnlock.pm or the SetStateOnLock.pm can be modified to achieve the same????
Now If I would like to achieve the objective of " if ticket state is closed then it should automatically get Unlocked" . Where do I need to modify.. in ForceState.pm or in ForceUnlock.pm or the SetStateOnLock.pm can be modified to achieve the same????
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: How to Chnage Ticket Status when ticket is Locked
That should happen upon close.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask