Adding Dynamic field to Customer Admin

Moderator: crythias

Post Reply
apolloit
Znuny newbie
Posts: 36
Joined: 01 Jun 2015, 10:17
Znuny Version: 6.0.28
Real Name: Michael James

Adding Dynamic field to Customer Admin

Post by apolloit »

Hello All,

Long time OTRS user, recently upgraded from the v4 appliance right upto 6.0.28 on a new CENTOS. Great process, even if I did need to rehearse and redo a it a few times. We're there now!

I'm trying to add a dynamic field to AdminCustomerCompany. It's for a client documentation URL.

I understand I need to copy code from Defaults.pm into Config.pm (near the bottom where "your own config settings" is indicated.

Having tried this many times - I'm just breaking the site with error 500s... until I remove it.

I know it's my fault - I just don't know why. Does anyone have any suggestions please? Thank you :) I've researched this as far as I can go, there's nothing to go on. I'm not a developer, but able to follow instructions and feedback results.

(Code below - this trips the site out in its default format, before I've amended the dynamic fields line)

Michael


Code: Select all

    $Self->{CustomerCompany} = {
        Name   => Translatable('Database Backend'),
        Module => 'Kernel::System::CustomerCompany::DB',
        Params => {
            # if you want to use an external database, add the
            # required settings
#            DSN  => 'DBI:odbc:yourdsn',
#            Type => 'mssql', # only for ODBC connections
#            DSN => 'DBI:mysql:database=customerdb;host=customerdbhost',
#            User => '',
#            Password => '',
            Table => 'customer_company',
#            ForeignDB => 0,    # set this to 1 if your table does not have create_time, create_by, change_time and change_by fields

            # CaseSensitive defines if the data storage of your DBMS is case sensitive and will be
            # preconfigured within the database driver by default.
            # If the collation of your data storage differs from the default settings,
            # you can set the current behavior ( either 1 = CaseSensitive or 0 = CaseINSensitive )
            # to fit your environment.
            #
#            CaseSensitive => 0,

            # SearchCaseSensitive will control if the searches within the data storage are performed
            # case sensitively (if possible) or not. Change this option to 1, if you want to search case sensitive.
            # This can improve the performance dramatically on large databases.
            SearchCaseSensitive => 0,
        },

        # company unique id
        CustomerCompanyKey             => 'customer_id',
        CustomerCompanyValid           => 'valid_id',
        CustomerCompanyListFields      => [ 'customer_id', 'name' ],
        CustomerCompanySearchFields    => [ 'customer_id', 'name' ],
        CustomerCompanySearchPrefix    => '*',
        CustomerCompanySearchSuffix    => '*',
        CustomerCompanySearchListLimit => 250,
        CacheTTL                       => 60 * 60 * 24, # use 0 to turn off cache

        Map => [
            # Info about dynamic fields:
            #
            # Dynamic Fields of type CustomerCompany can be used within the mapping (see example below).
            # The given storage (third column) then can also be used within the following configurations (see above):
            # CustomerCompanySearchFields, CustomerCompanyListFields
            #
            # Note that the columns 'frontend' and 'readonly' will be ignored for dynamic fields.

            # var, frontend, storage, shown (1=always,2=lite), required, storage-type, http-link, readonly
            [ 'CustomerID',             'CustomerID', 'customer_id', 0, 1, 'var', '', 0 ],
            [ 'CustomerCompanyName',    'Customer',   'name',        1, 1, 'var', '', 0 ],
            [ 'CustomerCompanyStreet',  'Street',     'street',      1, 0, 'var', '', 0 ],
            [ 'CustomerCompanyZIP',     'Zip',        'zip',         1, 0, 'var', '', 0 ],
            [ 'CustomerCompanyCity',    'City',       'city',        1, 0, 'var', '', 0 ],
            [ 'CustomerCompanyCountry', 'Country',    'country',     1, 0, 'var', '', 0 ],
            [ 'CustomerCompanyURL',     'URL',        'url',         1, 0, 'var', '[% Data.CustomerCompanyURL | html %]', 0 ],
            [ 'CustomerCompanyComment', 'Comment',    'comments',    1, 0, 'var', '', 0 ],
            [ 'ValidID',                'Valid',      'valid_id',    0, 1, 'int', '', 0 ],

            # Dynamic field example
#            [ 'DynamicField_Name_Y', undef, 'Name_Y', 0, 0, 'dynamic_field', undef, 0 ],
        ],
    };
skullz
Znuny superhero
Posts: 638
Joined: 24 Feb 2012, 03:58
Znuny Version: LTS and Features
Real Name: Mo Azfar
Location: Kuala Lumpur, MY
Contact:

Re: Adding Dynamic field to Customer Admin

Post by skullz »

Perhaps share the apache log..let say ur dynamic field name (customer) is URL

Code: Select all


            # Dynamic field example
          [ 'DynamicField_URL', undef, 'URL', 0, 0, 'dynamic_field', undef, 0 ],
        ],
    };

    # ---------------------------------------------------- #
    # ---------------------------------------------------- #
    #                                                      #
    # end of your own config options!!!                    #
    #                                                      #
    # ---------------------------------------------------- #
    # ---------------------------------------------------- #
My Github
OTRS CE/LTS Discord Channel
Cant Update Package Anymore ? Check This

Professional OTRS, Znuny & OTOBO services: efflux.de/en
Free and premium add-ons: English
root
Administrator
Posts: 4011
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Adding Dynamic field to Customer Admin

Post by root »

H,
apolloit wrote: 13 May 2020, 23:46 Having tried this many times - I'm just breaking the site with error 500s... until I remove it.
I'm pretty sure is has to do with your Kernel/Config.pm and the last lines in it. Let me explain:
apolloit wrote: 13 May 2020, 23:46

Code: Select all

    $Self->{CustomerCompany} = {
        Name   => Translatable('Database Backend'),
This Translatable function was introduced later than your initial version. Check if the last lines in your Kernel/Config.pm looks like the one in the distributed example: https://github.com/OTRS/otrs/blob/rel-6 ... m.dist#L94

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
apolloit
Znuny newbie
Posts: 36
Joined: 01 Jun 2015, 10:17
Znuny Version: 6.0.28
Real Name: Michael James

Re: Adding Dynamic field to Customer Admin

Post by apolloit »

Thank you for the replies!

Roy - I can confirm that my Config.pm *IS* from my OTRS4 which has been copied back into place with each version upgrade.

So my intention is to try the new version you kindly referred me to (with my old variables), and I will test this out of business hours later.

I'll report back accordingly, and many thanks again for pointing this out.

Michael
apolloit
Znuny newbie
Posts: 36
Joined: 01 Jun 2015, 10:17
Znuny Version: 6.0.28
Real Name: Michael James

Re: Adding Dynamic field to Customer Admin

Post by apolloit »

Hello again Roy,

Thank you - I can confirm that adding:
use Kernel::Config::Defaults; # import Translatable()
into the bottom of Config.pm (above use base) - WORKED, and I can now see my dynamic field for editing.

I have tried to add the Customer dynamic field in Ticket::Frontend::AgentTicketZoom###DynamicField (along with some existing "ticket based" dynamic fields) but I'm unable to get the new Customer one to show. I have populated it with data.

Would you happen to know what else I need to visit, as my research isn't yielding a solution. Apologies if I'm missing something fundamental again.

Thank you once again for the help!

Michael.
apolloit
Znuny newbie
Posts: 36
Joined: 01 Jun 2015, 10:17
Znuny Version: 6.0.28
Real Name: Michael James

Re: Adding Dynamic field to Customer Admin

Post by apolloit »

Please disregard last message - I fully resolved the issue by changing the dynamic field line in Config.pm. I set "1" under the "shown" column.

Just brilliant now - thanks for the help.

Michael.
Post Reply