Out of Office don't change State

Dont create your support topics here! No new topics with questions allowed!

Moderator: crythias

Forum rules
Dont create your support topics here! No new topics with questions allowed!
Post Reply
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Out of Office don't change State

Post by crythias »

Scenario: "I want to receive Out Of Office notifications as articles from customer but I don't want the state (such as Pending or Closed) to change to Open due to this."

Easy enough:

OOO.xml place in Kernel/Config/Files:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<otrs_config version="1.0" init="Application">
    <ConfigItem Name="PostMaster::PreFilterModule###111-OoO" Required="0" Valid="0">
                <Description Translatable="1">Module to Allow Out of Office to not change state.</Description>
        <Group>Ticket</Group>
        <SubGroup>Core::PostMaster</SubGroup>
        <Setting>
            <Hash>
                <Item Key="Module">Kernel::System::PostMaster::Filter::OutOfOffice</Item>
                <Item Key="OutOfOfficeString">Out of Office</Item>
            </Hash>
        </Setting>
    </ConfigItem>
</otrs_config>
And a Filter: Kernel/System/PostMaster/Filters/OutOfOffice.pm

Code: Select all

# --
# 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::PostMaster::Filter::OutOfOffice;

use strict;
use warnings;

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

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

    $Self->{Debug} = $Param{Debug} || 0;

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

    return $Self;
}

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

    # check needed stuff
    for (qw(JobConfig GetParam)) {
        if ( !$Param{$_} ) {
            $Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
            return;
        }
    }

    # get config options
    my %Config;
    my $OOOString;
    if ( $Param{JobConfig} && ref( $Param{JobConfig} ) eq 'HASH' ) {
        %Config = %{ $Param{JobConfig} };
        if ( $Config{OutOfOfficeString} ) {
            $OOOString = $Config{OutOfOfficeString};
        } else {
            $Self->{LogObject}->Log(
                'Priority' => 'error',
                'Message' => 'Need Out of Office String to parse!',
            );
            return;
        }
    }

    if ( !$Param{TicketID} ) {
        # no TicketID, not a followup
        return 1;
    }

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

    if ( $Param{GetParam}->{'Subject'} =~ /$OOOString/i) {
        $Param{GetParam}->{'X-OTRS-FollowUp-State'} = $Ticket{State};
    }

    return 1;
}

1;
This will survive updates and should be enabled in SysConfig.
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
vincent13
Znuny newbie
Posts: 43
Joined: 28 May 2013, 12:38
Znuny Version: 3.2000
Company: cpr sncf

Re: Out of Office don't change State

Post by vincent13 »

Hello,
ok thks for the howtos.

So simply in fact you test the subject then reinject the status, right ?

where in sysconfig to enable ?

thsk by advance.
vincent
lab : otrs 5rc1 test : otrs 3.3.15 prod : cluster 3.3.15
vincent13
Znuny newbie
Posts: 43
Joined: 28 May 2013, 12:38
Znuny Version: 3.2000
Company: cpr sncf

Re: Out of Office don't change State

Post by vincent13 »

Enable in sysconfig -> Core:PostMaster.
lab : otrs 5rc1 test : otrs 3.3.15 prod : cluster 3.3.15
gwpse
Znuny newbie
Posts: 1
Joined: 12 Dec 2016, 13:50
Znuny Version: 4.x, 5.x

Re: Out of Office don't change State

Post by gwpse »

Hello,

I applied this solution in OTRS 5.x and received error "Got no ...." for every object type from list. (I changed source to qw( ) to got separatelly each type).

Crythias, could you rewrite source to 5.x version compatible, pleeeeease.

Best regards
elbobo
Znuny newbie
Posts: 1
Joined: 24 Jun 2015, 15:29
Znuny Version: 5.0.16

Re: Out of Office don't change State

Post by elbobo »

This is not working anymore on OTRS 5.0.x

I changed this:

Code: Select all

for (qw(ConfigObject LogObject MainObject TicketObject)) {
    #    $Self->{$_} = $Param{$_} || die "Got no $_!";
    #}
To:

Code: Select all

# new port
our @ObjectDependencies = (
    'Kernel::System::Config',
    'Kernel::System::Log',
    'Kernel::System::Main',
    'Kernel::System::Ticket',
);
But I still get this error:
[Fri May 05 17:50:38.145767 2017] [:error] [pid 1257] Can't call method "TicketGet" on an undefined value at /usr/share/otrs//Kernel/System/PostMaster/Filter/OutOfOffice.pm line 73.\n
Any ideas on what needs to be ported as well?
kakajot
Znuny newbie
Posts: 5
Joined: 28 Feb 2013, 12:22
Znuny Version: 5.0.10
Company: Hochschule München

Re: Out of Office don't change State

Post by kakajot »

Hey crythias!

I try your programm on my OTRS 5.0.10 (on CentOS Linux) and get a error:
**************************
ERROR: OTRS-otrs.Console.pl-Maint::PostMaster::Read-68 Perl: 5.16.3 OS: linux Time: Tue Jul 25 11:59:14 2017

Message: ???

Traceback (26923):
Module: Kernel::System::Console::Command::Maint::PostMaster::Read::Run Line: 103
Module: (eval) Line: 444
Module: Kernel::System::Console::BaseCommand::Execute Line: 438
Module: Kernel::System::Console::InterfaceConsole::Run Line: 86
Module: ../../bin/otrs.Console.pl Line: 38
****************************

Can you help me? :(

Oh, I send the "mail" via:
"cat ./mail-von-OutOfOffice.txt | ../../bin/otrs.Console.pl Maint::PostMaster::Read"
because it is our Testsystem without a email-connection!
wheelchair
Znuny newbie
Posts: 1
Joined: 03 Oct 2017, 16:02
Znuny Version: 5.0.10

Re: Out of Office don't change State

Post by wheelchair »

Hey all!

Have a look at this: https://github.com/wendelb/OTRS-OutOfOffice
This will work with OTRS 5.*

Regards
fuchsMDIKT
Znuny newbie
Posts: 2
Joined: 28 Apr 2020, 14:58
Znuny Version: 6.0.23
Real Name: johannes fuchs

Re: Out of Office don't change State

Post by fuchsMDIKT »

newer solution for znuny / otrs 6 community edition
https://github.com/znuny/Znuny4OTRS-OutOfOfficeFilter
Post Reply