[SOLVED]Customer User add dynamic Field

Moderator: crythias

Post Reply
chrotha
Znuny newbie
Posts: 93
Joined: 29 Jun 2018, 13:44
Znuny Version: 6.x.x/7.0.x
Real Name: Ruben Sardinha

[SOLVED]Customer User add dynamic Field

Post by chrotha »

Hey guys,

I've been trying to add my own dynamic field that has been created on the OTRS dynamic field area.
I've coded it under the Defaults.pm Customer User configuration with the following code:

Code: Select all

[ 'DynamicField_CentroCusto', undef, Translatable('Centro de Custo'), 0,  0, 'dynamic_field', undef, 0, undef, undef],
So in full it looks something like this:

Code: Select all

[ 'UserTitle',        Translatable('Title or salutation'), 'title',          1, 0, 'var', '', 0, undef, undef ],
            [ 'UserFirstname',    Translatable('Firstname'),           'first_name',     1, 1, 'var', '', 0, undef, undef ],
            [ 'UserLastname',     Translatable('Lastname'),            'last_name',      1, 1, 'var', '', 0, undef, undef ],
            [ 'UserLogin',        Translatable('Username'),            'login',          1, 1, 'var', '', 0, undef, undef ],
            [ 'UserPassword',     Translatable('Password'),            'pw',             0, 0, 'var', '', 0, undef, undef ],
            [ 'UserEmail',        Translatable('Email'),               'email',          1, 1, 'var', '', 0, undef, undef ],
#            [ 'UserEmail',        Translatable('Email'),               'email',          1, 1, 'var', '[% Env("CGIHandle") %]?Action=AgentTicketCompose;ResponseID=1;TicketID=[% Data.TicketID | uri %];ArticleID=[% Data.ArticleID | uri %]', 0, '', 'AsPopup OTRSPopup_TicketAction' ],
            [ 'UserCustomerID',   Translatable('CustomerID'),          'customer_id',    0, 1, 'var', '', 0, undef, undef ],
#            [ 'UserCustomerIDs',  Translatable('CustomerIDs'),         'customer_ids',   1, 0, 'var', '', 0, undef, undef ],
            [ 'DynamicField_CentroCusto', undef, Translatable('Centro de Custo'), 0,  0, 'dynamic_field', undef, 0, undef, undef],
            [ 'UserPhone',        Translatable('Phone'),               'phone',          1, 0, 'var', '', 0, undef, undef ],
            [ 'UserFax',          Translatable('Fax'),                 'fax',            1, 0, 'var', '', 0, undef, undef ],
            [ 'UserMobile',       Translatable('Mobile'),              'mobile',         1, 0, 'var', '', 0, undef, undef ],
            [ 'UserStreet',       Translatable('Street'),              'street',         1, 0, 'var', '', 0, undef, undef ],
            [ 'UserZip',          Translatable('Zip'),                 'zip',            1, 0, 'var', '', 0, undef, undef ],
            [ 'UserCity',         Translatable('City'),                'city',           1, 0, 'var', '', 0, undef, undef ],
            [ 'UserCountry',      Translatable('Country'),             'country',        1, 0, 'var', '', 0, undef, undef ],
            [ 'UserComment',      Translatable('Comment'),             'comments',       1, 0, 'var', '', 0, undef, undef ],
            [ 'ValidID',          Translatable('Valid'),               'valid_id',       0, 1, 'int', '', 0, undef, undef ],
Even though I can't seem to get the dynamic field when I try to create a customer user.
I've added some screenshots as shown below
Capture.PNG
As you can see there's no such thing as a field called Centro de Custo.
CostCenter.png
Here's the dynamic Field configuration.

Can you guys give me a hand or at least try to tell me what's wrong?

Thanks in advance
You do not have the required permissions to view the files attached to this post.
Last edited by chrotha on 28 Jan 2019, 16:29, edited 1 time in total.
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Customer User add dynamic Field

Post by RStraub »

Oh no, this is wrong.

Please undo the changes in Defaults.pm. you NEVER want to edit Defaults.pm.

What you WANT to do is:
- copy the whole block "$Self->{CustomerUser}" FROM the Defaults.pm TO the Config.pm
- create a correlating column in the database

So for your example:

Code: Select all

[ 'DynamicField_CentroCusto', undef, Translatable('Centro de Custo'), 0,  0, 'dynamic_field', undef, 0, undef, undef],
maybe use:

Code: Select all

[ 'CentroCusto', 'Centro de Custo', 'centrocusto'), 1,  0, 'var', 0],
and add a column 'centrocusto' to the table "customer_user".
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
chrotha
Znuny newbie
Posts: 93
Joined: 29 Jun 2018, 13:44
Znuny Version: 6.x.x/7.0.x
Real Name: Ruben Sardinha

Re: Customer User add dynamic Field

Post by chrotha »

Hey Rolf,

Thanks for the help.

I copied the Defaults.pm Customer User and pasted it in the Config.pm with the new dynamic field and it's working fine.

Once again thanks for the help. :)
Post Reply