[SOLVED] Generic Agent: Execute Custom Module Parameters

English! place to talk about OTRS development, programming and coding

Moderator: tto

CJBok
OTRS newbie
Posts: 5
Joined: 10 May 2017, 09:46
OTRS Version?: 5.0.16
Real Name: CJ Bok
Company: Eurofins

[SOLVED] Generic Agent: Execute Custom Module Parameters

Postby CJBok » 10 May 2017, 13:38

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
OTRS guru
Posts: 2047
Joined: 13 Mar 2014, 09:16
OTRS Version?: 5.0.14
Real Name: Rolf Straub

Re: Generic Agent: Execute Custom Module Parameters

Postby RStraub » 10 May 2017, 13:42

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 5.0.14 -- MariaDB -- Ubuntu 16 LTS

CJBok
OTRS newbie
Posts: 5
Joined: 10 May 2017, 09:46
OTRS Version?: 5.0.16
Real Name: CJ Bok
Company: Eurofins

Re: Generic Agent: Execute Custom Module Parameters

Postby CJBok » 10 May 2017, 13:59

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
OTRS guru
Posts: 2047
Joined: 13 Mar 2014, 09:16
OTRS Version?: 5.0.14
Real Name: Rolf Straub

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

Postby RStraub » 10 May 2017, 15:07

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 5.0.14 -- MariaDB -- Ubuntu 16 LTS


Return to “OTRS Developers”

Who is online

Users browsing this forum: No registered users and 3 guests