[SOLVED] Generic Agent: Execute Custom Module Parameters

English! place to talk about development, programming and coding
Post Reply
CJBok
Znuny newbie
Posts: 5
Joined: 10 May 2017, 09:46
Znuny Version: 5.0.16
Real Name: CJ Bok
Company: Eurofins

[SOLVED] Generic Agent: Execute Custom Module Parameters

Post by CJBok »

I am trying to pass through some parameters from Generic Agent: Execute Custom Module to the actual Module. However for some reason the parameters are not send to the Module. (Module itself gets executed just fine)


Image


Code: Select all

package Custom::Kernel::Modules::CalcCosts;

use strict;
use warnings;

sub new {
	my ($Type, %Param) = @_;
	my $Self = {};
	bless( $Self, $Type);
	return $Self;
}

sub Run {
	my ($Self, %Param) = @_;
	
	$Kernel::OM->Get('Kernel::System::Log')->Log (
		Priority => 'info',
		Message => "Test: " . $Param{SomeValue,
	);	
}
Last edited by CJBok on 10 May 2017, 13:59, edited 1 time in total.
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Generic Agent: Execute Custom Module Parameters

Post by RStraub »

Hey there,

a) you are missing a closing "}" on the last line :)
b) Try accessing $Param{Data}->{SomeValue}

If you are unsure what is written in a variable, use this dumper block (needs a ref to a variable as parameter):

Code: Select all

    use Data::Dumper;
    my $message = Dumper(\%Param);
    $Kernel::OM->Get('Kernel::System::Log')->Log(
        Priority => 'error',
        Message  => $message,
    );
The contents are then dumped to the otrs and apache2 error log.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
CJBok
Znuny newbie
Posts: 5
Joined: 10 May 2017, 09:46
Znuny Version: 5.0.16
Real Name: CJ Bok
Company: Eurofins

Re: Generic Agent: Execute Custom Module Parameters

Post by CJBok »

RStraub wrote: If you are unsure what is written in a variable, use this dumper block (needs a ref to a variable as parameter):

Code: Select all

    use Data::Dumper;
    my $message = Dumper(\%Param);
    $Kernel::OM->Get('Kernel::System::Log')->Log(
        Priority => 'error',
        Message  => $message,
    );
The contents are then dumped to the otrs and apache2 error log.
Thank you RStraub! The dumper function did the trick.
Apparently its $Param{New}->{SomeValue};

Not sure why word New was chosen, but the dumper function revealed it.
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: [SOLVED] Generic Agent: Execute Custom Module Parameters

Post by RStraub »

Oh right, probably because a generic agent usually updates tickets, thus holds the parameters that are to be set in the "New" hash.

Glad it works now :)
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Post Reply