Two DBs as customer database and predefined company name

Moderator: crythias

Locked
maringer
Znuny newbie
Posts: 3
Joined: 04 Feb 2016, 15:28
Znuny Version: 5.0.6
Real Name: Alexander Maringer

Two DBs as customer database and predefined company name

Post by maringer »

Hi,

I'm not new to OTRS, but I hava a problem at the moment, where I don't get anywhere.

I want to connect 2 databases as customer databases to my OTRS.
The first one is the general otrs database. The second is a database where I have all clients, but not the company. Now I want to predefine the company key. Some extract of my Config.pm:

Code: Select all

package Kernel::Config;

use strict;
use warnings;
use utf8;

sub Load {
    my $Self = shift;

    $Self->{'DatabaseHost'} = '127.0.0.1';
    $Self->{'Database'} = 'otrs5';
    $Self->{'DatabaseUser'} = 'otrs5';
    $Self->{'DatabasePw'} = 'EfClZP6xHqSk9TLz';
    $Self->{'DatabaseDSN'} = "DBI:mysql:database=$Self->{Database};host=$Self->{DatabaseHost};";

    $Self->{Home} = '/opt/otrs';

    # CustomerUser 1
    $Self->{CustomerUser1} = {
        Name   => 'Database Backend 2',
        Module => 'Kernel::System::CustomerUser::DB',
        Params => {
            User => 'otrs5_cust2',
            Password => '*****',
            DSN => "DBI:mysql:database=otrs5_cust2;host=$Self->{DatabaseHost}",
            Table => 'customer_user',
            CaseSensitive => 0,
        },

        # customer unique id
        CustomerKey => 'login',

        # customer #
#        CustomerID             => '2',
        CustomerID             => 'customer_id2',
        CustomerValid          => 'valid_id',

        #   email address like "John Doe" <john.doe@domain.com> can be constructed from the fields.
        CustomerUserListFields => [ 'first_name', 'last_name', 'email' ],

        CustomerUserSearchFields           => [ 'login', 'first_name', 'last_name' ],
        CustomerUserSearchPrefix           => '*',
        CustomerUserSearchSuffix           => '*',
        CustomerUserSearchListLimit        => 250,
        CustomerUserPostMasterSearchFields => ['email'],
        CustomerUserNameFields             => [ 'title', 'first_name', 'last_name' ],
        CustomerUserEmailUniqCheck         => 1,

        CustomerCompanySupport => 1,
        CacheTTL => 0,
        ReadOnly => 1,
        Map => [

            # note: Login, Email and CustomerID needed!
            # var, frontend, storage, shown (1=always,2=lite), required, storage-type, http-link, readonly, http-link-target, link class(es)
            [ 'UserTitle',      'Title',      'title',      1, 0, 'var', '', 0 ],
            [ 'UserFirstname',  'Firstname',  'first_name', 1, 1, 'var', '', 0 ],
            [ 'UserLastname',   'Lastname',   'last_name',  1, 1, 'var', '', 0 ],
            [ 'UserLogin',      'Username',   'login',      1, 1, 'var', '', 0 ],
            [ 'UserPassword',   'Password',   'pw',         0, 0, 'var', '', 0 ],
            [ 'UserEmail',      'Email',      'email',      1, 1, 'var', '', 0 ],
#            [ 'UserEmail',      'Email', 'email',           1, 1, 'var', '[% Env("CGIHandle") %]?Action=AgentTicketCompose;ResponseID=1;TicketID=[% Data.TicketID | uri %];ArticleID=[% Data.ArticleID | uri %]', 0, '', 'AsPopup OTRSPopup_TicketAction' ],
            [ 'UserCustomerID', 'CustomerID', 'customer_id2', 0, 1, 'var', '', 0 ],
#            [ 'UserCustomerIDs', 'CustomerIDs', 'customer_ids', 1, 0, 'var', '', 0 ],
            [ 'UserPhone',        'Phone',       'phone',        1, 0, 'var', '', 0 ],
            [ 'UserFax',          'Fax',         'fax',          1, 0, 'var', '', 0 ],
            [ 'UserMobile',       'Mobile',      'mobile',       1, 0, 'var', '', 0 ],
            [ 'UserStreet',       'Street',      'street',       1, 0, 'var', '', 0 ],
            [ 'UserZip',          'Zip',         'zip',          1, 0, 'var', '', 0 ],
            [ 'UserCity',         'City',        'city',         1, 0, 'var', '', 0 ],
            [ 'UserCountry',      'Country',     'country',      1, 0, 'var', '', 0 ],
            [ 'UserComment',      'Comment',     'comments',     1, 0, 'var', '', 0 ],
            [ 'ValidID',          'Valid',       'valid_id',     0, 1, 'int', '', 0 ],
        ],

        # default selections
        Selections => {},

    };
    # ---------------------------------------------------- #
    # ---------------------------------------------------- #
    #                                                      #
    # end of your own config options!!!                    #
    #                                                      #
    # ---------------------------------------------------- #
    # ---------------------------------------------------- #
}

# ---------------------------------------------------- #
# needed system stuff (don't edit this)                #
# ---------------------------------------------------- #

use base qw(Kernel::Config::Defaults);

# -----------------------------------------------------#

1;
I tried different things to predefine the "CustomerID", but without success. Could I get any hint how to do this?

And I want to get the name of the second data base source in the "Customer User Management" page for selecting the correct database. Is this possible? If I choose another data source, then I get the selection in the dropdown box.
Locked