[SOLVED]Is that possible to shown child ticketin Report function ?

English! place to talk about development, programming and coding
Post Reply
franceswong0129
Znuny newbie
Posts: 12
Joined: 22 Jan 2019, 10:32
Znuny Version: ITSM 6

[SOLVED]Is that possible to shown child ticketin Report function ?

Post by franceswong0129 »

Dear all,

After splitting the ticket into different child tickets, is that possible to shown the relation of child ticket and parent ticket in the report that provided by otrs ?
Screenshot (3).png
Thank you so much !

Best regards,
Frances Wong
You do not have the required permissions to view the files attached to this post.
Last edited by franceswong0129 on 18 Feb 2019, 03:26, edited 1 time in total.
franceswong0129
Znuny newbie
Posts: 12
Joined: 22 Jan 2019, 10:32
Znuny Version: ITSM 6

Re: Is that possible to shown child ticketin Report function ?

Post by franceswong0129 »

Dear all,

Or is that possible to make the linked-object shown as an attributes in the Stats DynamicList ?

Thank you once again!

Best regards,
Frances Wong
skullz
Znuny superhero
Posts: 618
Joined: 24 Feb 2012, 03:58
Znuny Version: LTS and Features
Real Name: Mo Azfar
Location: Kuala Lumpur, MY
Contact:

Re: Is that possible to shown child ticketin Report function ?

Post by skullz »

Nope..as the dynamic list data is from TicketGet api which dont include linked ticket value..
unless u know the sql to get the linked item, you can build it by using Static stats instead
franceswong0129
Znuny newbie
Posts: 12
Joined: 22 Jan 2019, 10:32
Znuny Version: ITSM 6

Re: Is that possible to shown child ticketin Report function ?

Post by franceswong0129 »

skullz wrote: 12 Feb 2019, 04:00 Nope..as the dynamic list data is from TicketGet api which dont include linked ticket value..
unless u know the sql to get the linked item, you can build it by using Static stats instead
Dear skullz,

Thank you so much for your reply! Is there any example on the implementation of sql in Static stats ? Becoz I have tried to copy the example from http://doc.otrs.com/doc/manual/develope ... de-example but it fails.

Best regards,
Frances Wong
skullz
Znuny superhero
Posts: 618
Joined: 24 Feb 2012, 03:58
Znuny Version: LTS and Features
Real Name: Mo Azfar
Location: Kuala Lumpur, MY
Contact:

Re: Is that possible to shown child ticketin Report function ?

Post by skullz »

Thats exactly how it supposed to be..
however under sub Run(), put you SQL instead of calling the Ticket API.

check the DB API for prepare statement and fetch
https://doc.otrs.com/doc/api/otrs/6.0/P ... ml#Prepare
https://doc.otrs.com/doc/api/otrs/6.0/P ... chrowArray
franceswong0129
Znuny newbie
Posts: 12
Joined: 22 Jan 2019, 10:32
Znuny Version: ITSM 6

Re: Is that possible to shown child ticketin Report function ?

Post by franceswong0129 »

skullz wrote: 12 Feb 2019, 06:37 Thats exactly how it supposed to be..
however under sub Run(), put you SQL instead of calling the Ticket API.

check the DB API for prepare statement and fetch
https://doc.otrs.com/doc/api/otrs/6.0/P ... ml#Prepare
https://doc.otrs.com/doc/api/otrs/6.0/P ... chrowArray
Dear skullz,
I have checked the error.log for the error. It wrote Got no DBObject.

Code: Select all

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

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

    # check all needed objects
    for my $Needed (
        qw(DBObject ConfigObject LogObject #<- marked this line with error
        TimeObject MainObject EncodeObject)
        )
    {
        $Self->{$Needed} = $Param{$Needed} || die "Got no $Needed";
    }

    # create needed objects
    $Self->{TypeObject}   = Kernel::System::Type->new( %{$Self} );
    $Self->{TicketObject} = Kernel::System::Ticket->new( %{$Self} );
    $Self->{QueueObject}  = Kernel::System::Queue->new( %{$Self} );

    return $Self;
}
Any ideas on this ? Thank you once again!

Best regards,
Frances Wong
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: Is that possible to shown child ticketin Report function ?

Post by reneeb »

Object handling has changed in OTRS4

Code: Select all

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

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

sub Run {
    my ($Self, %Param) = @_;
    
    my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
    ...
}
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
franceswong0129
Znuny newbie
Posts: 12
Joined: 22 Jan 2019, 10:32
Znuny Version: ITSM 6

Re: Is that possible to shown child ticketin Report function ?

Post by franceswong0129 »

reneeb wrote: 12 Feb 2019, 17:01 Object handling has changed in OTRS4

Code: Select all

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

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

sub Run {
    my ($Self, %Param) = @_;
    
    my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
    ...
}
Dear reneeb,

Thank you so much for your helping.
Unluckily I encountered another problems-- empty excel file is exported based on the following code.
If a csv file is exported then error occurs with the line :Can't use string ("138") as as ARRAY ref while in use at /opt/otrs/Kernel/System/CSV.pm
Sometimes otrs cannot recognize the Stats pm that I have written-> I can't pick my.pm file in OTRS as the object type.

Code: Select all

sub Run {
    my ($Self, %Param) = @_;
    
    my $DBObject = $Kernel::OM->Get('Kernel::System::DB');

    # Check needed stuff.
    for my $ParamName (qw(StartYear StartMonth StartDay EndYear EndMonth EndDay)) {
        if ( !$Param{$ParamName} ) {
            $Kernel::OM->Get('Kernel::System::Log')->Log(
                Priority => 'error',
                Message  => "Need $ParamName!",
            );
            return;
        }
    }

    # set report title
    my $Title = 'Parent And Child Ticket Number';

    # table headlines
    my @HeadData = (
        'Parent Ticket',
        'Child Ticket',
    );

    my @Data;
    my $ParentNumber;
    my $ChildNumber;

    my $SQL = "SELECT target_key FROM link_relation";

    $DBObject->Prepare(SQL => $SQL, Limit => 15);

    while ($DBObject->FetchrowArray()) {
    push @Data, $Row[0];
}
    return ( [$Title], [@HeadData], @Data );
}
Any ideas for such the situation ?
Thank you so much !!!!!!

Best regards,
Frances Wong
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: Is that possible to shown child ticketin Report function ?

Post by reneeb »

Code: Select all

    while ($DBObject->FetchrowArray()) {
    push @Data, $Row[0];
}
should be

Code: Select all

    while (my @Row = $DBObject->FetchrowArray()) {
        push @Data, [$Row[0]];
    }
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
franceswong0129
Znuny newbie
Posts: 12
Joined: 22 Jan 2019, 10:32
Znuny Version: ITSM 6

Re: Is that possible to shown child ticketin Report function ?

Post by franceswong0129 »

reneeb wrote: 13 Feb 2019, 11:37

Code: Select all

    while ($DBObject->FetchrowArray()) {
    push @Data, $Row[0];
}
should be

Code: Select all

    while (my @Row = $DBObject->FetchrowArray()) {
        push @Data, [$Row[0]];
    }
Dear reneeb and all others,
Thank you so much for your helping. It works!

Best regards,
Frances Wong
Post Reply