[SOLVED] Escalationresponsetimestop event trigger

Moderator: crythias

Locked
nautilus
Znuny newbie
Posts: 7
Joined: 29 Jul 2016, 11:23
Znuny Version: 5.0.12

[SOLVED] Escalationresponsetimestop event trigger

Post by nautilus »

Hi,

how can an agent fire the event Escalationresponsetimestop? I mean, is there an action in Ticket Details Panel firing the event Escalationresponsetimestop?

Thanks a lot
Last edited by nautilus on 30 Aug 2016, 18:02, edited 3 times in total.
wurzel
Znuny guru
Posts: 3273
Joined: 08 Jul 2010, 22:25
Znuny Version: x.x.x
Real Name: Florian

Re: Escalationresponsetimestop event trigger

Post by wurzel »

Hi,

write a external article (phone outbound, reply or external note)

Flo
OTRS 2025 SILVER (Prod)
OTRS 2025 auf Debian 12 (Test)
Znuny 7.x latest version testing auf Debian 12

-- Ich beantworte keine Forums-Fragen PN - No PN please

I won't answer to unfriendly users any more. A greeting and regards are just polite.
nautilus
Znuny newbie
Posts: 7
Joined: 29 Jul 2016, 11:23
Znuny Version: 5.0.12

Re: Escalationresponsetimestop event trigger

Post by nautilus »

Thanks,

now I would like to try something different: i.e. executing a custom module with admin GUI -> Generic Agent -> job
So I have followed these steps:
1) added a new job executing custom module GAModules::TriggerTicketEscalationResponseTimeStop
2) created a new perl module TriggerTicketEscalationResponseTimeStop.pm in /opt/otrs/Custom/GAModules/

Code: Select all

#!/usr/bin/perl

# This module is triggered by a generic agent and will set
# the current time to a dynamic field

package GAModules::TriggerTicketEscalationResponseTimeStop;

use strict;
use warnings;
use utf8;
use lib '/opt/otrs/';
use lib '/opt/otrs/Kernel/cpan-lib';
use lib '/opt/otrs/Custom';

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

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

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

    my $TicketObject= $Kernel::OM->Get('Kernel::System::Ticket');
    my ($OwnerID, $Owner) = $TicketObject->OwnerCheck(
        TicketID => $Param{TicketID},
    );

    my $Success = $TicketObject->TicketEscalationResponseTimeStop(
        TicketID => $Param{TicketID},
        UserID   => $OwnerID,
    );
}
1;
3) copied /opt/otrs/Kernel/System/Ticket.pm in /opt/otrs/Custom/Kernel/System/Ticket.pm
3) added a new sub in /opt/otrs/Custom/Kernel/System/Ticket.pm just before section # COMPAT: to OTRS 1.x and 2.x (can be removed later)

Code: Select all

=item TicketEscalationResponseTimeStop()

set ticket escalation response time to zero

    my $Success = $TicketObject->TicketEscalationResponseTimeStop(
        TicketID => $Param{TicketID},
        UserID   => $Param{UserID},
    );

=cut

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

    # check needed stuff
    for my $Needed (qw(TicketID UserID)) {
        if ( !defined $Param{$Needed} ) {
            $Kernel::OM->Get('Kernel::System::Log')->Log(
                Priority => 'error',
                Message  => "Need $Needed!"
            );
            return;
        }
    }

    my %Ticket = $Self->TicketGet(
        TicketID      => $Param{TicketID},
        UserID        => $Param{UserID},
        DynamicFields => 0,
    );

    # get database object
    my $DBObject = $Kernel::OM->Get('Kernel::System::DB');

        # update escalation times with 0
        my %EscalationTimes = (
            EscalationResponseTime => 'escalation_response_time',
        );

        TIME:
        for my $Key ( sort keys %EscalationTimes ) {

            # check if table update is needed
            next TIME if !$Ticket{$Key};

            # update ticket table
            $DBObject->Do(
                SQL =>
                    "UPDATE ticket SET $EscalationTimes{$Key} = 0, change_time = current_timestamp, "
                    . " change_by = ? WHERE id = ?",
                Bind => [ \$Param{UserID}, \$Ticket{TicketID}, ],
            );
        }

    # clear ticket cache
    $Self->_TicketCacheClear( TicketID => $Param{TicketID} );

    return 1;
}
User tests are positives
I am not a perl programmer, so suggestions are welcome!
Locked