Custom Ticket Event Handlers

Moderator: crythias

Post Reply
steeman
Znuny newbie
Posts: 67
Joined: 22 May 2013, 11:35
Znuny Version: 3.3.2
Real Name: Philip Steeman
Company: VIVES

Custom Ticket Event Handlers

Post by steeman »

I followed the following instructions:
viewtopic.php?f=60&t=10090

I've got this working in otrs version 3.2 when I do the following:
- make a xml-file in /opt/otrs/Kernel/Config/Files/
- make a pm-file in /opt/otrs/Kernel/System/Ticket/Event

But the same config doesn't seem to work in version 3.3.3

Philip
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Custom Ticket Event Handlers

Post by crythias »

steeman wrote:But the same config doesn't seem to work in version 3.3.3
Not enough information to diagnose.
Errors? Problems? Notifications?
What is it doing? What is it not doing? "Not working" isn't enough to troubleshoot.
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
steeman
Znuny newbie
Posts: 67
Joined: 22 May 2013, 11:35
Znuny Version: 3.3.2
Real Name: Philip Steeman
Company: VIVES

Re: Custom Ticket Event Handlers

Post by steeman »

I've made a file Philip.xml in directory /opt/otrs/Kernel/Config/Files with the following content:

http://users.khbo.be/steeman/otrs/Philip.xml

There I call a perl-module Philip.pm in directory /opt/otrs/Kernel/Ticket/Event with the following content

http://users.khbo.be/steeman/otrs/Philip.pm

I use the following code to see ,if otrs get's there when I create a new ticket
sub new {
my ( $Type, %Param ) = @_;

open (f, ">/tmp/philip1.log");
print f "I'm in new\n";
close (f);
...


But that file isn't created.
There is also no info in log.

In version 3.2.? I've got this working without a problem. There is always a possibility that I made an error, but I think there is something changed since version 3.3.
If I'm correct I even think I tested it in version 3.2.12 and after a upgrade to 3.3.3 the same files didn't work anymore?

Philip

Philip
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Custom Ticket Event Handlers

Post by crythias »

First, you probably only need to set the event (.xml) for those events you're actively reacting to.
Next, Kernel/System/Event.pm is new in 3.3 vs 3.2
You may want to perldoc Event.pm for more information
Check Kernel/System/Ticket/Event/Test.pm for a sample

Below is a snippet of "working" ConfigItem from Ticket.xml

Code: Select all

    <ConfigItem Name="Ticket::EventModulePost###110-AcceleratorUpdate" Required="0" Valid="1">
        <Description Translatable="1">Updates the ticket index accelerator.</Description>
        <Group>Ticket</Group>
        <SubGroup>Core::Ticket</SubGroup>
        <Setting>
            <Hash>
                <Item Key="Module">Kernel::System::Ticket::Event::TicketAcceleratorUpdate</Item>
                <Item Key="Event">TicketStateUpdate|TicketQueueUpdate|TicketLockUpdate</Item>
            </Hash>
        </Setting>
    </ConfigItem>
Things to check:
Item is enabled/checked in SysConfig
.xml is readable by system.
ZZZAuto.pm or ZZZAAuto.pm has reference to your Event. (try rebuildConfig)

Use the logging system instead of your own files.

Code: Select all

$Self->{LogObject}->Log( Priority => 'info', Message => "I reached this point in my code" );
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
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Custom Ticket Event Handlers

Post by reneeb »

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

open (f, ">/tmp/philip1.log");
print f "I'm in new\n";
close (f);
...
You shouldn't open a file for your own in OTRS. The MainObject has a FileWrite method. If you do it yourself, you should check for errors

Code: Select all

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

open (f, ">/tmp/philip1.log") or die $!;
print f "I'm in new\n";
close (f);
...
And you shouldn't do it in "new", but in "Run"...
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
steeman
Znuny newbie
Posts: 67
Joined: 22 May 2013, 11:35
Znuny Version: 3.3.2
Real Name: Philip Steeman
Company: VIVES

Re: Custom Ticket Event Handlers

Post by steeman »

...

Things to check:
Item is enabled/checked in SysConfig

What do you mean by this?

Philip
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Custom Ticket Event Handlers

Post by crythias »

steeman wrote:Item is enabled/checked in SysConfig

What do you mean by this?
I'm not sure how to answer your question.
Search SysConfig for the .xml entry you've created.
Make sure the checkbox on the left is checked, therefore enabling your entry.

Unless you had the .xml as required, it's probably not enabled.
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
steeman
Znuny newbie
Posts: 67
Joined: 22 May 2013, 11:35
Znuny Version: 3.3.2
Real Name: Philip Steeman
Company: VIVES

Re: Custom Ticket Event Handlers

Post by steeman »

Everything seems to work now with the following xml-file (all the rest was OK):

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<otrs_config version="1.0" init="Changes">
  <ConfigItem Name="Ticket::EventModulePost###Test" Required="0" Valid="1">
    <Description Translatable="1">test</Description>
    <Group>Ticket</Group>
    <SubGroup>Core::Ticket</SubGroup>
    <Setting>
      <Hash>
        <Item Key="Module">Kernel::System::Ticket::Event::Philip</Item>
        <Item Key="Event">ArticleCreate|TicketCreate</Item>
      </Hash>
    </Setting>
  </ConfigItem>
</otrs_config>
Thanks for your help

Philip
Last edited by crythias on 24 Dec 2013, 15:04, edited 1 time in total.
Reason: [code] tags
Post Reply