Need CustomerCompany->CustomerCompanyKey in Kernel/Config.pm!

Moderator: crythias

Locked
caesar305
Znuny newbie
Posts: 7
Joined: 05 Feb 2015, 08:11
Znuny Version: 4.0.5

Need CustomerCompany->CustomerCompanyKey in Kernel/Config.pm!

Post by caesar305 »

Hello, new user to OTRS. I'm trying to configure a secondary CustomerCompany backend. I added to Config.pm:

Code: Select all

$Self->{CustomerCompany2} = {
    Name => 'SugarCRMAccounts',
    Module => 'Kernel::System::CustomerCompany::DB',
    Params => {# ---------------------------------------------------- #
                # needed system stuff (don't edit this) #
#            Type => 'mssql', # only for ODBC connections# ---------------------------------------------------- #
        DSN => 'DBI:mysql:database=itpsugar;host=x.x.x.x', #use base qw(Kernel::Config::Defaults)
        User => 'root',
        Password => 'xxxxxxxx',# -----------------------------------------------------#
                # $SQL .= " FROM $Self->{CustomerTable} WHERE ";
        #Table => 'customer_user LEFT JOIN address_table ON customer_user.column_name=address_table.column_name ',1;
                Table => 'account LEFT JOIN account_cstm ON account.id=account_cstm.id_c',
    },
    # customer unique id
    CustomerKey => 'id',
    # customer #
    CustomerID => 'itp_crm_account_id_c',
    CustomerCompanyListFields => [ 'itp_crm_account_id_c', 'name' ],
    CustomerCompanySearchFields => ['itp_crm_account_id_c', 'name'],
    CustomerCompanySearchPrefix => '',
    CustomerCompanySearchSuffix => '*',
    CustomerCompanySearchListLimit => 250,
    CacheTTL => 0, # use 0 to turn off cache
    # show not own tickets in customer panel, CompanyTickets
    CustomerUserExcludePrimaryCustomerID => 0,


    Map => [
            # var, frontend, storage, shown (1=always,2=lite), required, storage-type, http-link, readonly
            [ 'CustomerID', 'CustomerID', 'itp_crm_account_id_c', 1, 1, 'var', '', 1 ],
            [ 'CustomerCompanyName', 'Customer', 'name', 1, 1, 'var', '', 1 ],
            [ 'CustomerCompanyStreet', 'Street', 'shipping_address_street', 1, 0, 'var', '', 1 ],
            [ 'CustomerCompanyZIP', 'Zip', 'shipping_address_postalcode', 1, 0, 'var', '', 1 ],
            [ 'CustomerCompanyCity', 'City', 'shipping_address_city', 1, 0, 'var', '', 1 ],
            [ 'CustomerCompanyCountry', 'Country', 'shipping_address_country', 1, 0, 'var', '', 1 ],
            [ 'CustomerCompanyURL', 'URL', 'website', 1, 0, 'var', '[% Data.CustomerCompanyURL | html %]', 0 ],
            [ 'CustomerCompanyComment', 'Comment', 'description', 1, 0, 'var', '', 1 ],
            [ 'ValidID', 'Valid', 'valid_id', 0, 1, 'int', '', 1 ],
        ],
     };
But I am receiving the following error: Need CustomerCompany->CustomerCompanyKey in Kernel/Config.pm! in apache error logs.
As far as I understand, I have already added the CustomerCompanyKey which is the line: CustomerKey => 'id'. What else am I missing?
caesar305
Znuny newbie
Posts: 7
Joined: 05 Feb 2015, 08:11
Znuny Version: 4.0.5

Re: Need CustomerCompany->CustomerCompanyKey in Kernel/Config.pm!

Post by caesar305 »

Ok, I realized I was using the CustomerUser config section instead of the CustomerCompany section. Now that I correctly added the parameters I am able to see a list of all the Customers from the backend database. I now have a new issue. When clicking the customer an error is generated and I am unable to view the customer's info. The logs only show:

[Thu Feb 5 15:35:46 2015] -e: Use of uninitialized value $What in hash element at /opt/otrs//Kernel/Config/Defaults.pm line 1700.
[Thu Feb 5 15:35:46 2015] -e: Use of uninitialized value $What in concatenation (.) or string at /opt/otrs//Kernel/Config/Defaults.pm line 1701.
Debug: Config.pm ->Get('') --> <undef>
[Thu Feb 5 15:35:46 2015] -e: Use of uninitialized value $What in hash element at /opt/otrs//Kernel/Config/Defaults.pm line 1704.
[Thu Feb 5 15:35:46 2015] -e: (in cleanup) Can't call method "Get" on an undefined value at /opt/otrs//Kernel/System/AuthSession/DB.pm line 583.
[Thu Feb 05 15:35:46 2015] [error] Can't use an undefined value as a HASH reference at /opt/otrs//Kernel/Modules/AdminCustomerCompany.pm line 296.\n\t(in cleanup) Can't call method "Get" on an undefined value at /opt/otrs//Kernel/System/AuthSession/DB.pm line 583.\n

Not sure what this means.

New config is as follows:

Code: Select all

 $Self->{CustomerCompany1} = {
        Name   => 'SugarCRM Accounts',
        Module => 'Kernel::System::CustomerCompany::DB',
        Params => {
            # if you want to use an external database, add the
            # required settings
        DSN  => 'DBI:mysql:database=itpsugar;host=xxxxxxx',
#            Type => 'mssql', # only for ODBC connections
#            DSN => 'DBI:mysql:database=customerdb;host=customerdbhost',
        User => 'root',
        Password => 'xxxxxx',
        Table => 'accounts LEFT JOIN accounts_cstm ON accounts.id=accounts_cstm.id_c',
        ForeignDB => 1,    # set this to 1 if your table does not have create_time, create_by, change_time and change_by fields

            # CaseSensitive will control if the SQL statements need LOWER()
            #   function calls to work case insensitively. Setting this to
            #   1 will improve performance dramatically on large databases.
            CaseSensitive => 0,
        },

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

        Map => [
            # var, frontend, storage, shown (1=always,2=lite), required, storage-type, http-link, readonly
            [ 'CustomerID', 'CustomerID', 'itp_crm_account_id_c', 1, 0, 'var', '', 1 ],
            [ 'CustomerCompanyName', 'Customer', 'name', 1, 0, 'var', '', 1 ],
            [ 'CustomerCompanyStreet', 'Street', 'shipping_address_street', 1, 0, 'var', '', 1 ],
            [ 'CustomerCompanyZIP', 'Zip', 'shipping_address_postalcode', 1, 0, 'var', '', 1 ],
            [ 'CustomerCompanyCity', 'City', 'shipping_address_city', 1, 0, 'var', '', 1 ],
            [ 'CustomerCompanyCountry', 'Country', 'shipping_address_country', 1, 0, 'var', '', 1 ],
            [ 'CustomerCompanyURL', 'URL', 'website', 1, 0, 'var', '[% Data.CustomerCompanyURL | html %]', 0 ],
            [ 'CustomerCompanyComment', 'Comment', 'description', 1, 0, 'var', '', 1 ],

        ],
    };

caesar305
Znuny newbie
Posts: 7
Joined: 05 Feb 2015, 08:11
Znuny Version: 4.0.5

Re: Need CustomerCompany->CustomerCompanyKey in Kernel/Config.pm!

Post by caesar305 »

In case this helps anyone I finally resolved the issue. The CustomerCompanyKey was set to the field 'id'. In our backend database the 'id' field is a GUID. Apparently otrs doesn't like this; perhaps it detects a guid/hash type in the code somewhere and ends up trying to do something rather then reading the result as a string. I ended up using another field as the ID and now it seems to work. The new field only has integers, about 5 characters in length.
Locked