[SOLVED]how to debug generic agent custom module

Moderator: crythias

Post Reply
draugael
Znuny newbie
Posts: 8
Joined: 13 Mar 2018, 16:56
Znuny Version: 6.0.5

[SOLVED]how to debug generic agent custom module

Post by draugael »

I try to create a module for a job but I don't know how to debug it.
My module change the owner of the ticket.

Code: Select all

#!/usr/bin/perl -w

package Kernel::Custom::ToLevelOne;

use strict;
use warnings;

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


sub new {

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

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

    # debug level
    $Self->{Debug} = $Param{Debug} || 0;

    return $Self;
}

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

    #get actual ticketOwner
    my ($OwnerID, $Owner) = $TicketObject->OwnerCheck(
        TicketID => $Param{TicketID},
    );

    #get queue name
    my $Queue = $QueueObject->QueueLookup(
        QueueID => $TicketObject->TicketQueueID(
            TicketID => $Param{TicketID},
        );
    );

    #get level 1 user
    my %User = $GroupObject->PermissionRoleUserGet(
        RoleID => $GroupObject->RoleLookup(
            Role => "assistant $Queue niveau 1",
        );
    );

    my $UserLevelOne = $User{1};

    #change ticketOwner
    my $Success = $TicketObject->TicketOwnerSet(
        TicketID => $Param{TicketID},
        NewUser  => $userLevelOne,
        UserID   => $OwnerID,
    );

}

1;
Thanks in advance


ps: sorry for my bad english
Last edited by draugael on 21 Mar 2018, 10:35, edited 1 time in total.
draugael
Znuny newbie
Posts: 8
Joined: 13 Mar 2018, 16:56
Znuny Version: 6.0.5

Re: how to debug generic agent custom module

Post by draugael »

I find the answer myself :D
I use the command:

Code: Select all

bin/otrs.Console.pl Dev::UnitTest::Run --directory GenericAgent
Post Reply