Expand SOAP response (Generic Interface)

Moderator: crythias

Locked
derfrank
Znuny newbie
Posts: 5
Joined: 20 Aug 2014, 17:08
Znuny Version: 4.0.2
Real Name: Frank Dietrich

Expand SOAP response (Generic Interface)

Post by derfrank »

Hi,

I use the Generic Interface (SOAP) to search all closed tickets. All required details (ticket id, customer id) I get with the function ‚TicketGet‘. But I miss the value ‚accounted time‘ of articles. The accumulated accounted time is needed to generate bills.
Is it possible to expand the response of ‚TicketGet‘ to this value? Where is the correct place to do this?

Thank you for your support. :)

(OTRS 3.3.8 on Debian Wheezy)
eandrex
Znuny expert
Posts: 213
Joined: 04 Nov 2012, 23:58
Znuny Version: OTRS 4.x
Real Name: Esteban
Company: NORTON DE COLOMBIA

Re: Expand SOAP response (Generic Interface)

Post by eandrex »

Create a copy of <OTRS_HOME>/ Kernel / GenericInterface / Operation / Ticket / TicketGet.pm in <OTRS_HOME> / Custom / Kernel / GenericInterface / Operation / Ticket

now open <OTRS_HOME> / Custom / Kernel / GenericInterface / Operation / Ticket / TicketGet.pm <-- the copy you just created

from line ~ 298 to 307 there should be this

Code: Select all

if ( !IsHashRefWithData( \%TicketEntry ) ) {

            $ErrorMessage = 'Could not get Ticket data'
                . ' in Kernel::GenericInterface::Operation::Ticket::TicketGet::Run()';

            return $Self->{TicketCommonObject}->ReturnError(
                ErrorCode    => 'TicketGet.NotValidTicketID',
                ErrorMessage => "TicketGet: $ErrorMessage",
            );
        }
right after it, paste this:

Code: Select all

$TicketEntry{TicketAccountedTime} = $Self->{TicketObject}->TicketAccountedTimeGet( TicketID => $TicketID ) || 0;
if you are using mod_perl, restart Apache.

that should do the trick.
derfrank
Znuny newbie
Posts: 5
Joined: 20 Aug 2014, 17:08
Znuny Version: 4.0.2
Real Name: Frank Dietrich

Re: Expand SOAP response (Generic Interface)

Post by derfrank »

Thank you for your fast answer.

But I got this error:
Can't load operation backend module Kernel::GenericInterface::Operation::Ticket::TicketGet!
This is the modified code:

Code: Select all

        if ( !IsHashRefWithData( \%TicketEntry ) ) {

            $ErrorMessage = 'Could not get Ticket data'
                . ' in Kernel::GenericInterface::Operation::Ticket::TicketGet::Run()';

            return $Self->{TicketCommonObject}->ReturnError(
                ErrorCode    => 'TicketGet.NotValidTicketID',
                ErrorMessage => "TicketGet: $ErrorMessage",
            );
        }

        $TicketEntry{TicketAccountedTime} = $Self->{TicketObject}->TicketAccountedTimeGet( TicketID => $TicketID ) || 0;

        # set Ticket entry data
        my $TicketBundle = {
            %TicketEntry,
        };
Do you have an idea?
If I delete the row, I still get the error.
eandrex
Znuny expert
Posts: 213
Joined: 04 Nov 2012, 23:58
Znuny Version: OTRS 4.x
Real Name: Esteban
Company: NORTON DE COLOMBIA

Re: Expand SOAP response (Generic Interface)

Post by eandrex »

Can you attach your modified TicketGet.pm ?
derfrank
Znuny newbie
Posts: 5
Joined: 20 Aug 2014, 17:08
Znuny Version: 4.0.2
Real Name: Frank Dietrich

Re: Expand SOAP response (Generic Interface)

Post by derfrank »

This is the modified TicketGet.pm
You do not have the required permissions to view the files attached to this post.
eandrex
Znuny expert
Posts: 213
Joined: 04 Nov 2012, 23:58
Znuny Version: OTRS 4.x
Real Name: Esteban
Company: NORTON DE COLOMBIA

Re: Expand SOAP response (Generic Interface)

Post by eandrex »

I just pasted the TicketGet.pm you just sent me in <OTRS_HOME>/Custom/Kernel/GenericInterface/Operation/Ticket/ directory and it is working as expected

Image

Did you restart apache ?
derfrank
Znuny newbie
Posts: 5
Joined: 20 Aug 2014, 17:08
Znuny Version: 4.0.2
Real Name: Frank Dietrich

Re: Expand SOAP response (Generic Interface)

Post by derfrank »

I forgot to set the correct permissions. ;)
Now it works perfectly.

Thank you very much.
kawasakai
Znuny newbie
Posts: 2
Joined: 05 Feb 2015, 16:07
Znuny Version: 4.0.3

Re: Expand SOAP response (Generic Interface)

Post by kawasakai »

I need the same feature. I tried to apply your patch, adding the line

Code: Select all

$TicketEntry{TicketAccountedTime} = $Self->{TicketObject}->TicketAccountedTimeGet( TicketID => $TicketID ) || 0;
but I have no success. I get the same error as the thread creator "500 Internal Server Error". I am using 4.0.5.
kawasakai
Znuny newbie
Posts: 2
Joined: 05 Feb 2015, 16:07
Znuny Version: 4.0.3

Re: Expand SOAP response (Generic Interface)

Post by kawasakai »

To answer myself, in newer Versions of OTRS (at least 4.0.3) it has to be:

Code: Select all

        $TicketEntry{TicketAccountedTime} = $TicketObject->TicketAccountedTimeGet( TicketID => $TicketID ) || 0;
Locked