How to return or send Tiket Subject?

English! place to talk about OTRS development, programming and coding
Post Reply
crynof
OTRS newbie
Posts: 24
Joined: 20 Mar 2020, 20:23
OTRS Version?: 6.0
Real Name: Camilo

How to return or send Tiket Subject?

Post by crynof »

Hi Friends!
I need to send a ticket subject (Ticket#2020012872000131 — Test Ticket) to other system through generic agent as invoker.

I tried to made that without sucess.

Anyone can help me pls?.

Many thanks!

jojo
Moderator
Posts: 14798
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: How to return or send Tiket Subject?

Post by jojo »

Are you Talking about a webservice? Or do you want to send data with the Generic Agent?
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com

crynof
OTRS newbie
Posts: 24
Joined: 20 Mar 2020, 20:23
OTRS Version?: 6.0
Real Name: Camilo

Re: How to return or send Tiket Subject?

Post by crynof »

Hi jojo!, i talking about webservice, send subject to other system through REST.

I tried to return the title and number ticket but I do not obtain at the same time to TicketObject data.

Cheers

jojo
Moderator
Posts: 14798
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: How to return or send Tiket Subject?

Post by jojo »

You would need to develop your own invoker using the internal PERL API. Or just use one of the existing (commercial) Invokers
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com

crynof
OTRS newbie
Posts: 24
Joined: 20 Mar 2020, 20:23
OTRS Version?: 6.0
Real Name: Camilo

Re: How to return or send Tiket Subject?

Post by crynof »

jojo wrote:
18 May 2020, 09:04
You would need to develop your own invoker using the internal PERL API. Or just use one of the existing (commercial) Invokers
Exactly I tried with that without success, but don't know how to return this Subject. The method that appears here to build Subject I obtained from OTRS DOC, but unknown how to merge on invoker code.

Here is my code.
package Kernel::GenericInterface::Invoker::Test::Test;

#use strict;
use warnings;
use Kernel::System::Ticket;
use Kernel::System::VariableCheck qw(IsString IsStringWithData);

our $ObjectManagerDisabled = 1;

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

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

# check needed params
if ( !$Param{DebuggerObject} ) {
return {
Success => 0,
ErrorMessage => "Got no DebuggerObject!"
};
}

#$Self->{DebuggerObject} = $Param{DebuggerObject};

$Self->{TicketObject} = Kernel::System::Ticket->new( %Param );

return $Self;
}

sub PrepareRequest {
# get ticket object

use Kernel::System::ObjectManager;
local $Kernel::OM = Kernel::System::ObjectManager->new();
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');

my $LogObject = $Kernel::OM->Get('Kernel::System::Log');
my $ArticleObject = $Kernel::OM->Get('Kernel::System::Ticket::Article');
my $UserObject = $Kernel::OM->Get('Kernel::System::User');
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
#--------------------------------------------------------------------------------

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

#my %Ticket = $TicketObject->TicketGet( TicketID => $Param{Data}->{TicketID} );



# get ticket attribute matches
my %Article = $ArticleObject->ArticleGet(
ArticleID => $Param{Data}->{ArticleID},
TicketID => $Param{Data}->{TicketID},
From => $Param{Data}->{From},
Body => $Param{Data}->{From},
SenderType => $Param{Data}->{SenderType},
);

my %Ticket = $TicketObject->TicketGet(
TicketID => $Param{Data}->{TicketID},
Type => $Param{Data}->{Type},
TicketNumber => $Param{Data}->{TicketNumber},
Title => $Param{Data}->{Title},
Queue => $Param{Data}->{Queue},
State => $Param{Data}->{State},
OwnerID => $Param{Data}->{OwnerID},
Priority => $Param{Data}->{Priority},
);





my $Subject = $Article->{Subject};
if ( $Article->{ArticleSend} ) {

my $TicketNumber = $TicketObject->TicketNumberLookup(
TicketID => $TicketID,
UserID => $Param{UserID},
);

# Build a subject
$Subject = $TicketObject->TicketSubjectBuild(
TicketNumber => $TicketNumber,
Subject => $Article->{Subject},
Type => 'New',
Action => 'Reply',
);

if ( !$Subject ) {
return {
Success => 0,
ErrorMessage =>
'The subject for the e-mail could not be generated. Please contact the system administrator'
};
}
}




return {
Success => 1,
Data => {
%Ticket,
}
};
}

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

# if there was an error in the response, forward it
if ( !$Param{ResponseSuccess} ) {
return {
Success => 0,
ErrorMessage => $Param{ResponseErrorMessage},
};
}

return {
Success => 1,
Data => $Param{Data},
};
}

1;
Cheers

jojo
Moderator
Posts: 14798
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: How to return or send Tiket Subject?

Post by jojo »

you should already have an existing ticket to use the invoker. So why do you want to create a new Subject?
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com

crynof
OTRS newbie
Posts: 24
Joined: 20 Mar 2020, 20:23
OTRS Version?: 6.0
Real Name: Camilo

Re: How to return or send Tiket Subject?

Post by crynof »

jojo wrote:
18 May 2020, 19:50
you should already have an existing ticket to use the invoker. So why do you want to create a new Subject?

It happens that I need to return the subject to be sent to another system as a new ticket notification. The problem occurs when trying to return the Title and NumberTicket in a single variable from the TicketObject, something similar to what the Subject does. That is why I wanted to build a subject from the information that the TicketObject gives me but I have not had good results. :/

jojo
Moderator
Posts: 14798
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: How to return or send Tiket Subject?

Post by jojo »

again, if you have already a new ticket you can use the information from TicketGet. I strongly suggest to hire an expert...
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com

Post Reply