Execute Custom Module - error "Module not found/could not be loaded"

Moderator: crythias

Locked
IgorD
Znuny newbie
Posts: 14
Joined: 15 Dec 2016, 16:47
Znuny Version: 5s Free

Execute Custom Module - error "Module not found/could not be loaded"

Post by IgorD »

Hello!
I create new job in GenericAgent. Created file in /Custom/SendmailChief.pm. For the "Execute Custom Module" to "Custom::SendmailChief" value. After the getting the error "Module Custom/SendmailChief.pm not found/could not be loaded"
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Execute Custom Module - error "Module not found/could not be loaded"

Post by RStraub »

Did you declare the package name in the .pm?

Like so:

Code: Select all

package SendmailChief;
Did you register it for OTRS in a .xml file?
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
IgorD
Znuny newbie
Posts: 14
Joined: 15 Dec 2016, 16:47
Znuny Version: 5s Free

Re: Execute Custom Module - error "Module not found/could not be loaded"

Post by IgorD »

I declare the package name as

Code: Select all

package Custom::SendmailChief;
In which .xml file need to register module?
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Execute Custom Module - error "Module not found/could not be loaded"

Post by RStraub »

Try without the "Custom::".

You can use any xml file, but best is to create a custom one, like so:

Code: Select all

vi ~otrs/Kernel/Config/Files/Some-Custom-Name.xml
to register a module write into the file:
(though this might only be needed for frontend modules, I'm not entirely sure)

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<otrs_config version="1.0" init="Application">
    <ConfigItem Name="Frontend::Module###SendmailChief" Required="0" Valid="1">
        <Description Translatable="1">Frontend module registration for the agent interface.</Description>
        <Group>Framework</Group>
        <SubGroup>Frontend::Agent::ModuleRegistration</SubGroup>
        <Setting>
            <Hash>
                <Item Key="Module">SendmailChief</Item>
            </Hash>
        </Setting>
    </ConfigItem>
</otrs_config>
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
IgorD
Znuny newbie
Posts: 14
Joined: 15 Dec 2016, 16:47
Znuny Version: 5s Free

Re: Execute Custom Module - error "Module not found/could not be loaded"

Post by IgorD »

Thank you. I created file Some-Custom-Name.xml
This file needs to be registered in the system OTRS?
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Execute Custom Module - error "Module not found/could not be loaded"

Post by RStraub »

It does as soon as you rebuild the SysConfig. Simplest to do so is click on the link "SysConfig" in the Admin-Frontend.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
IgorD
Znuny newbie
Posts: 14
Joined: 15 Dec 2016, 16:47
Znuny Version: 5s Free

Re: Execute Custom Module - error "Module not found/could not be loaded"

Post by IgorD »

I watched in "SysConfig" and found my module. But the error remained. Maybe the problem in package structure ?

Code: Select all

#!/usr/bin/perl -w

package SendmailChief;

use strict;
use warnings;

use lib "/opt/otrs";
use lib "/opt/otrs/Kernel/cpan-lib";
use lib "/opt/otrs/Custom";

use Kernel::System::Email;

my $ticketnumber = $ARGV[0];
my $ticketid = $ARGV[1];


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

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

    # 0=off; 1=on;
    $Self->{Debug} = $Param{Debug} || 0;

    return $Self;
}

sub Run {
        my ( $Self, %Param ) = @_;
        my $MailTo = 'chief@domain.com';
        my $Message = 'Wait approved';

    $Self->{SendmailObject}->Send(
        From => 'OTRS1' . ' <'
              . 'otrs1@domain.com' . '>',
        To => $MailTo,
        Subject => '[Ticket#'.$ticketnumber.'] wait approved',
        MimeType => 'text/plain',
        Charset => 'utf-8',
        Body => $Message,
        Loop => 1,
    );
}

RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Execute Custom Module - error "Module not found/could not be loaded"

Post by RStraub »

Can you post the absolut path to the file? If it's really

Code: Select all

/Custom/SendmailChief.pm
then it's probably wrong. Do you mean it's "~otrs/Custom/SendmailChief.pm" ?
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
IgorD
Znuny newbie
Posts: 14
Joined: 15 Dec 2016, 16:47
Znuny Version: 5s Free

Re: Execute Custom Module - error "Module not found/could not be loaded"

Post by IgorD »

I found an error in the packet structure. Fixed. The module was found!

Code: Select all

#!/usr/bin/perl -w

package SendmailChief;

use strict;
use warnings;

use lib "/opt/otrs";
use lib "/opt/otrs/Kernel/cpan-lib";
use lib "/opt/otrs/Custom";

use Kernel::System::Email;

my $ticketnumber = $ARGV[0];
my $ticketid = $ARGV[1];


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

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

    # 0=off; 1=on;
    $Self->{Debug} = $Param{Debug} || 0;

    return $Self;
}

sub Run {
        my ( $Self, %Param ) = @_;
        my $MailTo = 'chief@domain.com';
        my $Message = 'Wait approved';

    $Self->{SendmailObject}->Send(
        From => 'OTRS1' . ' <'
              . 'otrs1@domain.com' . '>',
        To => $MailTo,
        Subject => '[Ticket#'.$ticketnumber.'] wait approved',
        MimeType => 'text/plain',
        Charset => 'utf-8',
        Body => $Message,
        Loop => 1,
    );
}

1;
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Execute Custom Module - error "Module not found/could not be loaded"

Post by RStraub »

Oh, okay.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
IgorD
Znuny newbie
Posts: 14
Joined: 15 Dec 2016, 16:47
Znuny Version: 5s Free

Re: Execute Custom Module - error "Module not found/could not be loaded"

Post by IgorD »

Thank you!!!
Locked