Escalation notification only to owner

Moderator: crythias

Post Reply
tomekliw
Znuny newbie
Posts: 32
Joined: 02 Dec 2010, 11:17
Znuny Version: 3
Location: Poland

Escalation notification only to owner

Post by tomekliw »

Hi,

Is there in OTRS a possibility to turn off escalation notifications for all agents in queue and leve it only for agent who locked ticket?
OTRS 3.1.10 on CentOS and MySql. Auth for customers and agents via both Active Directory and local database.
teymuralizade
Znuny newbie
Posts: 9
Joined: 05 Jul 2011, 08:16
Znuny Version: 2.4.10
Real Name: Teymur Alizade
Company: AzeriCard LTD

Re: Escalation notification only to owner

Post by teymuralizade »

I have the same question. Can anyone help ?
renee
Znuny expert
Posts: 241
Joined: 06 Feb 2009, 11:15
Znuny Version: 3.0.x
Company: Perl-Services.de
Contact:

Re: Escalation notification only to owner

Post by renee »

You can write your own module for GenericAgent. This module is for configuration:

Kernel/Config/GenericAgentEscalation.pm

Code: Select all

# --
# Kernel/Config/GenericAgentEscalation.pm - config file of generic agent
# Copyright (C) 2011 perl-services.de, http://perl-services.de/
# --
# $Id: GenericAgentEscalation.pm,v 1.1 2011/05/24 15:30:12 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::Config::GenericAgentEscalation;

use strict;
use warnings;

use Encode;

use vars qw($VERSION @ISA @EXPORT %Jobs);
require Exporter;
@ISA     = qw(Exporter);
@EXPORT  = qw(%Jobs);
$VERSION = qw($Revision: 1.1 $) [1];

# -----------------------------------------------------------------------
# config options
# -----------------------------------------------------------------------
%Jobs = (

    # [name of job] -> send escalation notification to ticket owner
    'EscalationToOwner' => {
        Escalation => 1,
        New        => {
            Module => 'Kernel::System::GenericAgent::NotifyOwner',
        },
    },
);

# -----------------------------------------------------------------------
# end of config options
# -----------------------------------------------------------------------

1;
And the GenericAgent module: Kernle/System/GenericAgent/NotifyOwner.pm

Code: Select all

# --
# Kernel/System/GenericAgent/NotifyOwner.pm - generic agent notifications
# Copyright (C) 2011 perl-services.de, http://perl-services.de/
# --
# $Id: NotifyOwner.pm,v 1.6 2011/07/25 20:55:55 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::GenericAgent::NotifyOwner;

use strict;
use warnings;

use vars qw(@ISA $VERSION);
$VERSION = qw($Revision: 1.6 $) [1];

sub new {
    my ( $Type, %Param ) = @_;

    # allocate new hash for object
    my $Self = {};
    bless( $Self, $Type );

    # check needed objects
    for (qw(DBObject ConfigObject LogObject TicketObject TimeObject EncodeObject)) {
        $Self->{$_} = $Param{$_} || die "Got no $_!";
    }

    # 0=off; 1=on;
    $Self->{Debug} = $Param{Debug} || 0;

    return $Self;
}

sub Run {
    my ( $Self, %Param ) = @_;

    # get ticket data
    my %Ticket = $Self->{TicketObject}->TicketGet(%Param);

    if ( !%Ticket ) {
        $Self->{LogObject}->Log(
            Priority => 'notice',
            Message  => 'No Ticket for ' . $Param{TicketID},
        );
        return 1;
    }

    # check if bussines hours is, then send escalation info
    my $CountedTime = $Self->{TimeObject}->WorkingTime(
        StartTime => $Self->{TimeObject}->SystemTime() - ( 10 * 60 ),
        StopTime => $Self->{TimeObject}->SystemTime(),
    );

    if ( !$CountedTime ) {
        if ( $Self->{Debug} ) {
            $Self->{LogObject}->Log(
                Priority => 'debug',
                Message =>
                    "Send not escalation for Ticket $Ticket{TicketNumber}/$Ticket{TicketID} because currently no working hours!",
            );
        }
        return 1;
    }

    # check if it's a escalation of escalation notification
    # check escalation times
    my $EscalationType = '';
    for my $Type (
        qw(FirstResponseTimeEscalation UpdateTimeEscalation SolutionTimeEscalation
        FirstResponseTimeNotification UpdateTimeNotification SolutionTimeNotification)
        )
    {
        if ( defined $Ticket{$Type} ) {
            if ( $Type =~ /TimeEscalation$/ ) {
                $EscalationType = 'Escalation';
                last;
            }
            elsif ( $Type =~ /TimeNotification$/ ) {
                $EscalationType = 'EscalationNotifyBefore';
                last;
            }
        }
    }

    # check
    if ( !$EscalationType ) {
        if ( $Self->{Debug} ) {
            $Self->{LogObject}->Log(
                Priority => 'debug',
                Message =>
                    "Can't send escalation for Ticket $Ticket{TicketNumber}/$Ticket{TicketID} because ticket is not escalated!",
            );
        }
        return;
    }

    # send agent notification
    $Self->{TicketObject}->SendAgentNotification(
        TicketID              => $Param{TicketID},
        CustomerMessageParams => \%Param,
        Type                  => $EscalationType,
        RecipientID           => $Ticket{OwnerID},
        UserID                => 1,
    );

    return 1;
}
(the code is untested)

Then you can run (in you terminal or via cron)

otrs.GenericAgent.pl -c Kernel::Config::GenericAgentEscalation
Need a Perl/OTRS developer? You can contact me at info@perl-services.de
Post Reply