How to add dynamicfields support for new front end modules

English! place to talk about development, programming and coding
Post Reply
mcontagious
Znuny newbie
Posts: 5
Joined: 07 Jun 2013, 09:28
Znuny Version: 3.2.0

How to add dynamicfields support for new front end modules

Post by mcontagious »

Hi,

I have created a new module for otrs and now I want to make use of dynamic fields feature for this new module.

I have created the following xml configuration for new module. Can any one provide me instructions on how to extend the dynamic fields feature for my new module.

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<otrs_config version="1.0" init="Application">
        <ConfigItem Name="Frontend::Module###AgentTimeSheets" Required="1" Valid="1">
        <Description Translatable="1">FrontendModuleRegistration for TimeSheets module.</Description>
        <Group>TimeSheets</Group>
        <SubGroup>Frontend::Agent::ModuleRegistration</SubGroup>
        <Setting>
            <FrontendModuleReg>
                <Title>TimeSheets</Title>
                <Group>TimeSheets</Group>
                <Description>TimeSheets</Description>
                <NavBarName>TimeSheets</NavBarName>
                <NavBar>
                    <Description>TimeSheets</Description>
                    <Name>TimeSheets</Name>
                    <Link>Action=AgentTimeSheets</Link>
                    <NavBar>TimeSheets</NavBar>
                    <Type>Menu</Type>
                    <Prio>8400</Prio>
                    <Block>ItemArea</Block>
                </NavBar>
            </FrontendModuleReg>
        </Setting>
    </ConfigItem>
</otrs_config>
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: How to add dynamicfields support for new front end modul

Post by reneeb »

This is how other frontend modules do it:

1) Add new Sysconfig option

Code: Select all

    <ConfigItem Name="Ticket::Frontend::CustomerTicketOverview###DynamicField" Required="0" Valid="1">
        <Description Translatable="1">Dynamic fields shown in the ticket overview screen of the customer interface. Possible settings: 0 = Disabled, 1 = Enabled, 2 = Enabled and required.</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Customer::TicketOverview</SubGroup>
        <Setting>
            <Hash>
            </Hash>
        </Setting>
    </ConfigItem>
2) use DynamicField modules in <Frontend>.pm

Code: Select all

use Kernel::System::DynamicField;
use Kernel::System::DynamicField::Backend;
use Kernel::System::VariableCheck qw(:all);
3) create needed objects in Method "new"

Code: Select all

    $Self->{DynamicFieldObject} = Kernel::System::DynamicField->new(%Param);
    $Self->{BackendObject}      = Kernel::System::DynamicField::Backend->new(%Param);
4) get list of dynamic fields from config in method "new"

Code: Select all

    $Self->{Config} = $Self->{ConfigObject}->Get("Ticket::Frontend::$Self->{Action}");

    # get the dynamic fields for this screen
    $Self->{DynamicField} = $Self->{DynamicFieldObject}->DynamicFieldListGet(
        Valid       => 1,
        ObjectType  => [ 'Ticket', 'Article' ],
        FieldFilter => $Self->{Config}->{DynamicField} || {},
    );
5) use that list in the method "Run". E.g.

Code: Select all

    # cycle trough the activated Dynamic Fields for this screen
    DYNAMICFIELD:
    for my $DynamicFieldConfig ( @{ $Self->{DynamicField} } ) {
        next DYNAMICFIELD if !IsHashRefWithData($DynamicFieldConfig);

        # extract the dynamic field value form the web request
        $DynamicFieldValues{ $DynamicFieldConfig->{Name} }
            = $Self->{BackendObject}->EditFieldValueGet(
            DynamicFieldConfig => $DynamicFieldConfig,
            ParamObject        => $Self->{ParamObject},
            LayoutObject       => $Self->{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
mcontagious
Znuny newbie
Posts: 5
Joined: 07 Jun 2013, 09:28
Znuny Version: 3.2.0

Re: How to add dynamicfields support for new front end modul

Post by mcontagious »

I have tried these steps already and did not work.

What we need to have in $Self->{Config}->{DynamicField}
mcontagious
Znuny newbie
Posts: 5
Joined: 07 Jun 2013, 09:28
Znuny Version: 3.2.0

Re: How to add dynamicfields support for new front end modul

Post by mcontagious »

Or tell me how to name the following configitem

<ConfigItem Name="Ticket::Frontend::CustomerTicketOverview###DynamicField" Required="0" Valid="1">

for new module I have created with the given xml configuration.
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: How to add dynamicfields support for new front end modul

Post by reneeb »

Ticket::Frontend::AgentTimeSheets###DynamicField
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
mcontagious
Znuny newbie
Posts: 5
Joined: 07 Jun 2013, 09:28
Znuny Version: 3.2.0

Re: How to add dynamicfields support for new front end modul

Post by mcontagious »

It is not working for me.

Is there any test module created to give demo on this topic ?
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: How to add dynamicfields support for new front end modul

Post by reneeb »

"It's not working for me" means what? Are there any error messages? how does your code look like? Did you add some debugging code*?



*

Code: Select all

$Self->{LogObject}->Log( Priority => error => Message => '<insert a useful message here>' );
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
Post Reply