Where to define values for "BuildSelection"

Moderator: crythias

Locked
Mugen
Znuny newbie
Posts: 10
Joined: 05 Sep 2016, 12:05
Znuny Version: 5.0.9

Where to define values for "BuildSelection"

Post by Mugen »

Hello!

I'd like to have a drop down menu instead of the number entry field at Ticket -> People -> Customer -> CustomerID

First time I applied it, I got an error because "OptionStrgHashRef" was replaced by "BuildSelection".
After replacing in my code, too (see below), I got still a error. But I don't know how to solve it:

Code: Select all

Can't call method "BuildSelection" on an undefined value at /opt/otrs//Kernel/Modules/AgentTicketEmail.pm line 3043.
Where/how to define the value for "BuildSelection"?

A college gave me something old: (AgentTicketEmail.pm)

Code: Select all

    #--Start MyCustomizedFS        #1452
    my %MyCuCustomerGroup= ();
    $MyCuCustomerGroup{SelectedID} = $Param{CustomerID} || '';
    my %MyCuCustomerGroups= $Self->{DBObject}->GetTableData(
        Table => 'mc_customer_groups',
        # Valid => 1,
        What => 'id, name'
    );
    $MyCuCustomerGroups{'999'} = '-';
    $Param{'MyCuCustomerIDStrg'} = $Self->{LayoutObject}->OptionStrgHashRef(
        Data => \%MyCuCustomerGroups,
        Name => 'MyCuCustomerID',
        %MyCuCustomerGroup,
    );
    #--Stop MyCustomizedFS 
    # get output back
    return $Self->{LayoutObject}->Output(TemplateFile => 'AgentTicketEmail', Data => \%Param);    # 1469  

How I applied it:

Code: Select all

        $LayoutObject->Block(    #3026
            Name => 'RichText',
            Data => \%Param,
        );
    }

    #--Start MyCustomizedFS
    my %MyCuCustomerGroup= ();
    $MyCuCustomerGroup{SelectedID} = $Param{CustomerID} || '';
    my $MyCuDBObject = $Kernel::OM->Get('Kernel::System::DB');
    $MyCuDBObject->Prepare(SQL => "SELECT id, name FROM mc_customer_groups");
    my %MyCuCustomerGroups= $MyCuDBObject->FetchrowArray();
        #Table => 'mc_customer_groups',
        ## Valid => 1,
        #What => 'id, name'
    #);
    $MyCuCustomerGroups{'999'} = '-';
    $Param{'MyCuCustomerIDStrg'} = $Self->{LayoutObject}->BuildSelection(
        Data => \%MyCuCustomerGroups,
        Name => 'MyCuCustomerID',
        %MyCuCustomerGroup,
    );
    #--Stop MyCustomizedFS

    # get output back
    return $LayoutObject->Output(     #3051  
(Only one part of the code, see attachment for the complete .pm)

Line 3043:

Code: Select all

    $Param{'MyCuCustomerIDStrg'} = $Self->{LayoutObject}->BuildSelection(    #3043  
(Only one part of the code, see attachment for the complete .pm)
You do not have the required permissions to view the files attached to this post.
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: Where to define values for "BuildSelection"

Post by reneeb »

replace $Self->{LayoutObject} with $LayoutObject
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
Mugen
Znuny newbie
Posts: 10
Joined: 05 Sep 2016, 12:05
Znuny Version: 5.0.9

Re: Where to define values for "BuildSelection"

Post by Mugen »

Okay... This solves the error itself. But my problem consists.

I have no idea about programming Java/JavaScript or Ajax, even more no clue in combination with Perl.
Perl is most time no problem, but OOPPerl is still difficult to me. Is there any template, how I can configure a dropdown menu from a SQL table to replace the "CustomerID" by "Department" in OTRS 5.0.9?
Locked