[SOLVED] Ticket List displaying current queue and the queue in which the ticket was created

Moderator: crythias

Locked
epferreira
Znuny newbie
Posts: 24
Joined: 23 Jun 2016, 15:49
Znuny Version: 4.0.1

[SOLVED] Ticket List displaying current queue and the queue in which the ticket was created

Post by epferreira »

Hello

I can't find out how to display both columns on the list that displays after a Ticket Search.

Here's why my company needs that feature:
  • . For the type RfC we have 2 queues available for selection when the customer opens a ticket: Planned Change | Emergency Change
    . The customer can now choose a service from the available list of services on the "Services" combo
    . After the ticket is opened the agents responsible for the approval will receive the mail notification for approval.
    If it is approved the ticket is channeled for the queue responsible to handle the selected service
    . When listing all the tickets of type RfC we would like to see, for statistical purposes, which ones were opened as "Planned Change" or "Emergency
    Change", but we can't because the only queue related column available ("QUEUE") is the one that shows the queue to which the ticket was moved after approval.
    . If we could display a "CREATED IN QUEUE" column we could then make a rational between both queue related columns.
Is there any configuration available that we're missing that could provide us this feature?


Thank you
Last edited by epferreira on 12 Aug 2016, 17:29, edited 1 time in total.
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: Ticket List displaying current queue and the queue in which the ticket was created

Post by reneeb »

That info is stored in Ticket history only. I would create a dynamic field "OriginQueue" and create a simple ticket event module that stores the queue name in that dynamic field when a ticket is created...
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
epferreira
Znuny newbie
Posts: 24
Joined: 23 Jun 2016, 15:49
Znuny Version: 4.0.1

Re: Ticket List displaying current queue and the queue in which the ticket was created

Post by epferreira »

So, it's guaranteed to be impossible to achieve this by changing some configuration in the Web Interface only?
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: Ticket List displaying current queue and the queue in which the ticket was created

Post by reneeb »

Yes, as "CreatedInQueue" is not an attribute returned by the TicketGet method...
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
epferreira
Znuny newbie
Posts: 24
Joined: 23 Jun 2016, 15:49
Znuny Version: 4.0.1

Re: Ticket List displaying current queue and the queue in which the ticket was created

Post by epferreira »

Ok. Thank you for the hints
epferreira
Znuny newbie
Posts: 24
Joined: 23 Jun 2016, 15:49
Znuny Version: 4.0.1

Re: Ticket List displaying current queue and the queue in which the ticket was created

Post by epferreira »

Hello

After quite a bit of searching and experimenting on Perl and OTRS, I've finally put the custom event module being executed each time a ticket is created. I've just added a bit of code to test general utils importing and message logging. The problem is that each time I create a ticket I receive the following error: "An error occurred while reading CGI reply (no response received)".

Can anyone give me a help on this?

Here's the custom module code:

Code: Select all


# --
# Store Original Queue on Dynamic Field
# --

package Kernel::System::Ticket::Event::CreatedInQueue;
#/opt/otrs/Custom/Kernel/System/Ticket/Event
use strict;
use warnings;

use Kernel::System::DynamicField;
use Kernel::System::DynamicField::Backend;
use Kernel::System::VariableCheck qw(:all);

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

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

=tried to comment this but the problem still remains
    # get needed objects
    for (qw(ConfigObject TicketObject LogObject TimeObject UserObject CustomerUserObject SendmailObject)) {
        $Self->{$_} = $Param{$_} || die "Got no $_!";
    }

    # create additional objects
    $Self->{DynamicFieldObject} = Kernel::System::DynamicField->new(
        EncodeObject => $Param{TicketObject}->{EncodeObject},
        MainObject   => $Param{TicketObject}->{MainObject},
        DBObject     => $Param{TicketObject}->{DBObject},
        %Param,
    );
    $Self->{BackendObject} = Kernel::System::DynamicField::Backend->new(
        EncodeObject => $Param{TicketObject}->{EncodeObject},
        MainObject   => $Param{TicketObject}->{MainObject},
        DBObject     => $Param{TicketObject}->{DBObject},
        TimeObject   => $Param{TicketObject}->{TimeObject},
        %Param,
    );
=cut

    return $Self;
}

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

#=enable only during debug
    $Self->{LogObject}->Log(
        Priority => 'debug',
        Message => 'Run() Dumping %Param:'
    );
    $Self->{LogObject}->Dumper(
        Data => %Param
    );
#=cut
	$Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );

    return 1;
}

1;
epferreira
Znuny newbie
Posts: 24
Joined: 23 Jun 2016, 15:49
Znuny Version: 4.0.1

Re: Ticket List displaying current queue and the queue in which the ticket was created

Post by epferreira »

Hello

I have fixed the issue. The problem was that I was using mixed code of version 3 and 4. Also the code was looking for parameters that could only be get on the run routine.

Everything looks ok based on the logs that I'm triggering. But the value of the dynamic field is not showing on the tickets list displayed in the queue view.
Could anyone give me a hint on the possible causes?

Here goes the correct code and the logs triggered by it:

Code: Select all

# --
# Store Original Queue on Dynamic Field
# --

package Kernel::System::Ticket::Event::CreatedInQueue;

use strict;
use warnings;

use Kernel::System::DynamicField;
use Kernel::System::DynamicField::Backend;
use Kernel::System::VariableCheck qw(:all);

our @ObjectDependencies = (
	'Kernel::System::Log',
	'Kernel::System::Ticket',
	'Kernel::System::DynamicField::Backend'
);

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

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

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

	#$Kernel::OM->Get('Kernel::System::Log')->Dumper($Param{Data});
	#$Kernel::OM->Get('Kernel::System::Log')->Dumper($Param);
	
	# Check needed parameters 	
	for(qw(Data Event Config)){
		if(!$Param{$_}){
			$Kernel::OM->Get('Kernel::System::Log')->Log(Priority => 'error', Message => "Need $_!");
		}
	}

	if ( $Param{Event} eq 'TicketCreate' ) {

		# Get ticket base object
		my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
		
		# Get created ticket object
		my %Ticket = $TicketObject->TicketGet(
			TicketID      => $Param{Data}->{TicketID},
			DynamicFields => 0,
		);
		
		# Get dyn field config of InitQueue
		my $DynamicFieldConfig = $Kernel::OM->Get('Kernel::System::DynamicField')->DynamicFieldGet(Name => 'InitQueue'); 
		
		# Set the value of InitQueue for the created ticket
		my $Success = $Kernel::OM->Get('Kernel::System::DynamicField::Backend')->ValueSet(
			DynamicFieldConfig => $DynamicFieldConfig,
			ObjectID => $Ticket{TicketID},
			Value => "THE_VALUE:: $Ticket{Queue}",
			UserID => $Param{UserID}
		);

		# Debug
		$Kernel::OM->Get('Kernel::System::Log')->Log(Priority => 'info', Message => "$Ticket{TicketID}");	
		$Kernel::OM->Get('Kernel::System::Log')->Log(Priority => 'info', Message => "The UserID: $Param{UserID}");
		$Kernel::OM->Get('Kernel::System::Log')->Log(Priority => 'info', Message => "Success: $Success");
		$Kernel::OM->Get('Kernel::System::Log')->Log(Priority => 'info', Message => "TICKET QUEUE: $Ticket{Queue}");
    }	
	
    return 1;
}

1;

The Logs:
[Fri Aug 12 09:59:30 2016][Info][Kernel::System::Ticket::Event::CreatedInQueue::Run] 105
[Fri Aug 12 09:59:30 2016][Info][Kernel::System::Ticket::Event::CreatedInQueue::Run] The UserID: 1
[Fri Aug 12 09:59:30 2016][Info][Kernel::System::Ticket::Event::CreatedInQueue::Run] Success: 1
[Fri Aug 12 09:59:30 2016][Info][Kernel::System::Ticket::Event::CreatedInQueue::Run] TICKET QUEUE: Raw
epferreira
Znuny newbie
Posts: 24
Joined: 23 Jun 2016, 15:49
Znuny Version: 4.0.1

Re: Ticket List displaying current queue and the queue in which the ticket was created

Post by epferreira »

Issue solved.

On Ticket ->Frontend::Agent::Ticket::ViewQueue, on default columns definition I didn't put the prefix DynamicField.

Hope these walkabouts help someone :)
Locked