[SOLVED]Internal Server Error

Moderator: crythias

Post Reply
AngelLR
OTRS newbie
Posts: 2
Joined: 18 Oct 2018, 11:07
OTRS Version?: 5.0.16
Real Name: Ángel

[SOLVED]Internal Server Error

Post by AngelLR » 18 Oct 2018, 16:05

SOLUTION:
After debug a bit the "AgentTicketCustom.pm" I realized that the error was relationed with a function called "DynamicFieldListGet". Then I thought that maybe I needed to copy some xml from the file "Tiket.xml" so I copied all the xml related to dynamic fields to my "TicketCustom.xml" and it worked. Here is the final code of my custom link:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<otrs_config version="1.0" init="Application">
    <ConfigItem Name="Frontend::Module###AgentTicketCustom" Required="0" Valid="1">
        <Description Translatable="1">Frontend module registration for the agent interface.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::ModuleRegistration</SubGroup>
        <Setting>
            <FrontendModuleReg>
                <Description Translatable="0">Nuevo ticket de vulnerabilidad.</Description>
                <Title Translatable="1">Nuevo ticket de vulnerabilidad</Title>
                <NavBarName>Ticket</NavBarName>
                <NavBar>
                    <Description Translatable="1">Nuevo ticket de vulnerabilidad.</Description>
                    <Name Translatable="1">Nuevo ticket de vulnerabilidad</Name>
                    <Link>Action=AgentTicketCustom</Link>
                    <LinkOption></LinkOption>
                    <NavBar>Ticket</NavBar>
                    <Type></Type>
                    <Block></Block>
                    <AccessKey>v</AccessKey>
                    <Prio>250</Prio>
                </NavBar>
                <Loader>
                    <JavaScript>Core.Agent.CustomerSearch.js</JavaScript>
                    <JavaScript>Core.Agent.TicketAction.js</JavaScript>
                </Loader>
            </FrontendModuleReg>
        </Setting>
    </ConfigItem>
<ConfigItem Name="Ticket::Frontend::AgentTicketCustom###Priority" Required="1" Valid="1">
        <Description Translatable="1">Sets the default priority for new Custom tickets in the agent interface.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Ticket::ViewCustomNew</SubGroup>
        <ValidateModule>Kernel::System::SysConfig::PriorityValidate</ValidateModule>
        <Setting>
            <String Regex="">3 normal</String>
        </Setting>
    </ConfigItem>
    <ConfigItem Name="Ticket::Frontend::AgentTicketCustom###ArticleType" Required="1" Valid="1">
        <Description Translatable="1">Sets the default article type for new Custom tickets in the agent interface.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Ticket::ViewCustomNew</SubGroup>
 <Setting>
            <String Regex="">Custom</String>
        </Setting>
    </ConfigItem>
    <ConfigItem Name="Ticket::Frontend::AgentTicketCustom###SenderType" Required="1" Valid="1">
        <Description Translatable="1">Sets the default sender type for new Custom ticket in the agent interface.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Ticket::ViewCustomNew</SubGroup>
        <Setting>
            <String Regex="">customer</String>
        </Setting>
    </ConfigItem>
    <ConfigItem Name="Ticket::Frontend::AgentTicketCustom::CustomerIDReadOnly" Required="1" Valid="1">
        <Description Translatable="1">Controls if CustomerID is read-only in the agent interface.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Ticket::ViewCustomNew</SubGroup>
        <Setting>
            <Option SelectedID="1">
                <Item Key="0" Translatable="1">No</Item>
                <Item Key="1" Translatable="1">Yes</Item>
            </Option>
        </Setting>
    </ConfigItem>
    <ConfigItem Name="Ticket::Frontend::AgentTicketCustom::AllowMultipleFrom" Required="1" Valid="1">
        <Description Translatable="1">Controls if more than one from entry can be set in the new Custom ticket in the agent interface.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Ticket::ViewCustomNew</SubGroup>
        <Setting>
            <Option SelectedID="1">
                <Item Key="0" Translatable="1">No</Item>
                <Item Key="1" Translatable="1">Yes</Item>
            </Option>
        </Setting>
    </ConfigItem>
    <ConfigItem Name="Ticket::Frontend::AgentTicketCustom###Subject" Required="1" Valid="1">
        <Description Translatable="1">Sets the default subject for new Custom tickets (e.g. 'Custom call') in the agent interface.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Ticket::ViewCustomNew</SubGroup>
        <Setting>
            <String Regex=""></String>
   </Setting>
    </ConfigItem>
    <ConfigItem Name="Ticket::Frontend::AgentTicketCustom###Body" Required="1" Valid="1">
        <Description Translatable="1">Sets the default note text for new teleCustom tickets. E.g 'New ticket via call' in the agent interface.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Ticket::ViewCustomNew</SubGroup>
        <Setting>
            <TextArea></TextArea>
        </Setting>
    </ConfigItem>
    <ConfigItem Name="Ticket::Frontend::AgentTicketCustom###StateDefault" Required="1" Valid="1">
        <Description Translatable="1">Sets the default next state for new Custom tickets in the agent interface.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Ticket::ViewCustomNew</SubGroup>
        <ValidateModule>Kernel::System::SysConfig::StateValidate</ValidateModule>
        <Setting>
            <String Regex="">open</String>
        </Setting>
    </ConfigItem>
    <ConfigItem Name="Ticket::Frontend::AgentTicketCustom###StateType" Required="1" Valid="1">
        <Description Translatable="1">Determines the next possible ticket states, after the creation of a new Custom ticket in the agent interface.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Ticket::ViewCustomNew</SubGroup>
        <Setting>
            <Array>
                <Item Translatable="1">open</Item>
                <Item Translatable="1">pending auto</Item>
                <Item Translatable="1">pending reminder</Item>
                <Item Translatable="1">closed</Item>
            </Array>
        </Setting>
    </ConfigItem>
    <ConfigItem Name="Ticket::Frontend::AgentTicketCustom###HistoryType" Required="1" Valid="1">
        <Description Translatable="1">Defines the history type for the Custom ticket screen action, which gets used for ticket history in the agent interface.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Ticket::ViewCustomNew</SubGroup>
        <Setting>
            <String Regex="">CustomCallCustomer</String>
</Setting>
    </ConfigItem>
    <ConfigItem Name="Ticket::Frontend::AgentTicketCustom###HistoryComment" Required="1" Valid="1">
        <Description Translatable="1">Defines the history comment for the Custom ticket screen action, which gets used for ticket history in the agent interface.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Ticket::ViewCustomNew</SubGroup>
        <Setting>
            <String Regex=""></String>
        </Setting>
    </ConfigItem>
    <ConfigItem Name="Ticket::Frontend::AgentTicketCustom###SplitLinkType" Required="0" Valid="1">
        <Description Translatable="1">Sets the default link type of splitted tickets in the agent interface.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Ticket::ViewCustomNew</SubGroup>
        <Setting>
            <Hash>
                <Item Key="LinkType" Translatable="1">ParentChild</Item>
                <Item Key="Direction" Translatable="1">Target</Item>
            </Hash>
        </Setting>
    </ConfigItem>

    <ConfigItem Name="Ticket::Frontend::AgentTicketCustom###ServiceMandatory" Required="0" Valid="1">
        <Description Translatable="1">Sets if service must be selected by the agent.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Ticket::ViewCustomNew</SubGroup>
        <Setting>
            <Option SelectedID="0">
                <Item Key="0" Translatable="1">No</Item>
                <Item Key="1" Translatable="1">Yes</Item>
            </Option>
        </Setting>
    </ConfigItem>
    <ConfigItem Name="Ticket::Frontend::AgentTicketCustom###SLAMandatory" Required="0" Valid="1">
        <Description Translatable="1">Sets if SLA must be selected by the agent.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Ticket::ViewCustomNew</SubGroup>
        <Setting>
            <Option SelectedID="0">
                <Item Key="0" Translatable="1">No</Item>
		<Item Key="1" Translatable="1">Yes</Item>
            </Option>
        </Setting>
    </ConfigItem>
</otrs_config>


Hello,

I created one OTRS module following the tutorial in chapter 3 of the documentation. My module adds a new link in Ticket's dropdown menu as follows:

- Some view
- Some view
- Some view
- Some view
- New phone ticket
- New email ticket
- New custom ticket <- this is my custom link
- Search

Here is the code of the link:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<otrs_config version="1.0" init="Application">
    <ConfigItem Name="Frontend::Module###AgentTicketCustom" Required="0" Valid="1">
        <Description Translatable="1">Frontend module registration for the agent interface.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::ModuleRegistration</SubGroup>
        <Setting>
            <FrontendModuleReg>
                <Description Translatable="0">New custom ticket.</Description>
                <Title Translatable="1">New custom ticket</Title>
                <NavBarName>Ticket</NavBarName>
                <NavBar>
                    <Description Translatable="1">New custom ticket.</Description>
                    <Name Translatable="1">New custom ticket</Name>
                    <Link>Action=AgentTicketCustom</Link>
                    <LinkOption></LinkOption>
                    <NavBar>Ticket</NavBar>
                    <Type></Type>
                    <Block></Block>
                    <AccessKey>v</AccessKey>
                    <Prio>250</Prio>
                </NavBar>
                <Loader>
                    <JavaScript>Core.Agent.CustomerSearch.js</JavaScript>
                    <JavaScript>Core.Agent.TicketAction.js</JavaScript>
                </Loader>
            </FrontendModuleReg>
        </Setting>
    </ConfigItem>
</otrs_config>

I also created an "AgentTicketCustom.pm" in "/opt/my_custom_ticket/Kernel/Modules/" which is a copy of the file "AgentTicketPhone.pm". I just replaced the line:

Code: Select all

package Kernel::Modules::AgentTicketPhone;
For this one:

Code: Select all

package Kernel::Modules::AgentTicketCustom;
Then I created my "AgentTicketCustom.tt" in "opt/my_custom_ticket/Kernel/Output/HTML/Templates/Standard/" which is also a copy of the file "AgentTicketPhone.tt".

Finally I linked my module using "module-tools/link.pl" and rebuilded the sysconfig using "/otrs/bin/otrs.Console.pl Maint::Config::Rebuild --cleanup-user-config".

I see my link but when I click on it i get the following error:

"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log."

At first I thought that maybe I had to register the action somewhere but the tutorial of the chapter 3 in the documentation doesn't say anything about that.

Can someone help me?

I am using OTRS 5.0.x and I have installed General Catalog and ITSMCore packages.

Thank you.


EDIT:

Ok, I realized that the problem is inside the "AgentTicketCustom.pm" because I copied the files of the tutorial in "How to extend OTRS" chapter and my custom link worked with them. I replaced the text "TicketPhone" for "TicketCustom" inside my "AgentTicketCustom.pm" but it didn't solve the problem.

After checking the server log I saw this error:

Code: Select all

[:error] [pid 5947] Can't use an undefined value as a HASH reference at /opt/otrs//Kernel/Modules/AgentTicketCustom.pm line 33.\n
This is the line of the code:

Code: Select all

 $Self->{DynamicField} = $Kernel::OM->Get('Kernel::System::DynamicField')->DynamicFieldListGet(
I thought that maybe $Self was undefined and I added this:

Code: Select all

    $Kernel::OM->Get('Kernel::System::Log')->Log(
        Priority => 'error',
        Message  => "$Self",
    );
And here is the log:

Code: Select all

ERROR: OTRS-CGI-10 Perl: 5.16.3 OS: linux Time: Fri Oct 19 09:25:32 2018

 Message: Kernel::Modules::AgentTicketCustom=HASH(0x563c9c894050)

 RemoteAddress: x.x.x.x
 RequestURI: /otrs/index.pl?Action=AgentTicketCustom

 Traceback (5889):
   Module: Kernel::Modules::AgentTicketCustom::new Line: 37
   Module: Kernel::System::Web::InterfaceAgent::Run Line: 1038
   Module: ModPerl::ROOT::ModPerl::Registry::opt_otrs_bin_cgi_2dbin_index_2epl::handler Line: 40
   Module: (eval) (v1.99) Line: 207
   Module: ModPerl::RegistryCooker::run (v1.99) Line: 207
   Module: ModPerl::RegistryCooker::default_handler (v1.99) Line: 173
   Module: ModPerl::Registry::handler (v1.99) Line: 32

[Fri Oct 19 09:25:32.135601 2018] [:error] [pid 5889] Can't use an undefined value as a HASH reference at /opt/otrs//Kernel/Modules/AgentTicketCustom.pm line 45.\n
And I am a bit stuck at this moment.

Is possible to debug the module?, if it is possible, how can I do it?

Thank you.

Post Reply