Out of Office don't change State

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

Moderator: crythias

User avatar
crythias
Moderator
Posts: 9921
Joined: 04 May 2010, 18:38
OTRS Version?: 4.0.x
Location: SouthWest Florida, USA
Contact:

Out of Office don't change State

Postby crythias » 06 Apr 2014, 01:22

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 4.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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
OTRS newbie
Posts: 43
Joined: 28 May 2013, 12:38
OTRS Version?: 3.2000
Company: cpr sncf

Re: Out of Office don't change State

Postby vincent13 » 17 Feb 2015, 10:44

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
OTRS newbie
Posts: 43
Joined: 28 May 2013, 12:38
OTRS Version?: 3.2000
Company: cpr sncf

Re: Out of Office don't change State

Postby vincent13 » 17 Feb 2015, 10:49

Enable in sysconfig -> Core:PostMaster.
lab : otrs 5rc1 test : otrs 3.3.15 prod : cluster 3.3.15

gwpse
OTRS newbie
Posts: 1
Joined: 12 Dec 2016, 13:50
OTRS Version?: 4.x, 5.x

Re: Out of Office don't change State

Postby gwpse » 12 Dec 2016, 14:01

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
OTRS newbie
Posts: 1
Joined: 24 Jun 2015, 15:29
OTRS Version?: 5.0.16

Re: Out of Office don't change State

Postby elbobo » 05 May 2017, 18:05

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
OTRS newbie
Posts: 5
Joined: 28 Feb 2013, 12:22
OTRS Version?: 5.0.10
Company: Hochschule München

Re: Out of Office don't change State

Postby kakajot » 25 Jul 2017, 12:30

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
OTRS newbie
Posts: 1
Joined: 03 Oct 2017, 16:02
OTRS Version?: 5.0.10

Re: Out of Office don't change State

Postby wheelchair » 03 Oct 2017, 16:33

Hey all!

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

Regards


Return to “Howtos”

Who is online

Users browsing this forum: sommerzeit and 1 guest