[SOLVED] GenericInterface::Invoker

Moderator: crythias

Locked
ossys
Znuny newbie
Posts: 8
Joined: 11 Dec 2014, 20:19
Znuny Version: 3.1.12
Real Name: Chad Cravens
Company: Open Source Systems, LLC

[SOLVED] GenericInterface::Invoker

Post by ossys »

I created an invoker module such as Kernel::GenericInterface::Invoker::Test:MyModule that is trigged on CreateTicket.

The module is registered, everything seems to be working very well.

However, in the PrepareRequest() method, I only receive the TicketID in my $Param{Data} object: $Param{Data}->{TicketID}

How do get access to some of the other fields of the newly created ticket? Such as the priority: $Param{Data}->{Priority}

Since the documentation around this is pretty sparse, any help with this would be greatly appreciated! Thanks!
Last edited by ossys on 16 Dec 2014, 17:17, edited 2 times in total.
eandrex
Znuny expert
Posts: 213
Joined: 04 Nov 2012, 23:58
Znuny Version: OTRS 4.x
Real Name: Esteban
Company: NORTON DE COLOMBIA

Re: GenericInterface::Invoker

Post by eandrex »

Well, add this above the "new" sub

Code: Select all

use Kernel::System::Ticket;
and in your new() method add this (before return $Self;)

Code: Select all

$Self->{TicketObject} = Kernel::System::Ticket->new( %Param );
and then, in your PrepareRequest ()

add this

Code: Select all

my %TicketInfo = $Self->{TicketObject}->TicketGet(
	TicketID => $Param{Data}->{TicketID},
	UserID => 1,
);
after that, in %TicketInfo you will get everythign you need

Code: Select all

$TicketInfo{Service}
$TicketInfo{Priority}
..
for more info http://otrs.github.io/doc/api/otrs/3.3/ ... et.pm.html
by the way, the ticket object depends on other objects (read the link above) so make sure they have been already created or create them if not.
ossys
Znuny newbie
Posts: 8
Joined: 11 Dec 2014, 20:19
Znuny Version: 3.1.12
Real Name: Chad Cravens
Company: Open Source Systems, LLC

Re: GenericInterface::Invoker

Post by ossys »

Awesome! That worked perfectly!

I did notice several StackOverflow and Forum questions regarding this where the common answer seemed to be to create and invoke a TicketGet web service with the TicketID rather than just instantiating a Ticket object. This would be very helpful information to provide in the docs on the section regarding invokers.

Thanks again!
skila
Znuny newbie
Posts: 4
Joined: 30 Apr 2015, 14:38
Znuny Version: 3.3.12
Real Name: Carlo Schilardi
Company: HP

Re: GenericInterface::Invoker

Post by skila »

I applied the suggested code in my invoker module Kernel::GenericInterface::Invoker::Test:MyModule.
The module is registred and it works well but in the PrepareRequest() method I still receive only the TicketID.
Can you help me?

Thanks.
OTRS 3.3.12 ITSM, FAQ, Win2012, Apache2+MysQL 5
Locked