[SOLVED] Retrieve companies from external backend

Moderator: crythias

Locked
luca
Znuny newbie
Posts: 5
Joined: 15 Oct 2014, 14:43
Znuny Version: 5.0.11

[SOLVED] Retrieve companies from external backend

Post by luca »

Hi all,

I'm trying to get OTRS working together with our CRM.
I would like OTRS to retrieve Companies and Company Users infos from our CRM database.
I've read a lot of posts reagarding mass import etc. telling that the best solution should be the configuration
of an external backend to let OTRS retrieve all the stuff from the CRM database(best in read-only access)

I have successfully configured in Config.pm an external backend for CustomerUsers, and now I see all the CustomerUsers
listed in "Customer User Administration" section.

This is my configuration:

Code: Select all

$Self->{CustomerUser1} = {
    Name => 'Database Datasource',
    Module => 'Kernel::System::CustomerUser::DB',
    Params => {
        # if you want to use an external database, add the required settings
#            DSN => 'DBI:odbc:yourdsn',
             Type => 'mysql', # only for ODBC connections
             DSN => 'DBI:mysql:database=database_mirror;host=localhost',
             User => 'myuser',
             Password => 'mypass',
             Table => 'USER_OTRS',
            # if your frontend is unicode and the charset of your
            # customer database server is iso-8859-1, use these options.
#           SourceCharset => 'iso-8859-1',
#           DestCharset => 'utf-8',

            # 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,
        },
    # customer unique id
    CustomerKey => 'username',

    # customer #
    CustomerID => 'username',
    CustomerValid => 'valid_id',
    CustomerUserListFields => ['name', 'surname', 'email'],
    CustomerUserSearchFields => ['username', 'surname', 'username'],
    CustomerUserSearchPrefix => '',
    CustomerUserSearchSuffix => '*',
    CustomerUserSearchListLimit => 250,
    CustomerUserPostMasterSearchFields => ['email'],
    CustomerUserNameFields => ['title','name','surname'],
    CustomerUserEmailUniqCheck => 1,
#    # show not own tickets in customer panel, CompanyTickets
#    CustomerUserExcludePrimaryCustomerID => 0,
#    # generate auto logins
#    AutoLoginCreation => 0,
#    AutoLoginCreationPrefix => 'auto',
#    # admin can change customer preferences
#    AdminSetPreferences => 1,
#    # cache time to live in sec. - cache any database queries
#    CacheTTL => 0,
#    # just a read only source
#    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
#        [ 'UserTitle',      'Title',      'title',      1, 0, 'var', '', 0 ],
        [ 'UserFirstname',  'Firstname',  'name', 1, 1, 'var', '', 0 ],
        [ 'UserLastname',   'Lastname',   'surname',  1, 1, 'var', '', 0 ],
        [ 'UserLogin',      'Username',   'username',      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"}&ArticleID=$Data{"ArticleID"}', 0 ],
        [ 'UserCustomerID', 'CustomerID', 'customer_id', 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 => {
        UserTitle => {
            'Mr.' => 'Mr.',
            'Mrs.' => 'Mrs.',
        },
    },
};

Now I have two main problems:

The first one is about Companies, I've not found how to configure an external backend to let OTRS retrieve data for Customers(the ones that should appear in "Customer administration" section).

The second problems is about CustomerUser editing. If I click on the username of a CustomerUser, the resulting form is completely blank and no error is shown in system logs. I know that the info for CustomerUser are not editable, but I expect at least to read the informations retrieved for all the fields configured.

Can anyone help me to find a solution to my problems?

Thanks in advance,

Luca
Last edited by luca on 01 Sep 2016, 16:30, edited 1 time in total.
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: Retrieve companies from external backend

Post by reneeb »

WRT your first problem: There is a $Self->{CustomerCompany} = {...} section in Kernel/Config/Defaults.pm. Copy that to Kernel/Config.pm and configure it...
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
luca
Znuny newbie
Posts: 5
Joined: 15 Oct 2014, 14:43
Znuny Version: 5.0.11

Re: Retrieve companies from external backend

Post by luca »

reneeb wrote:WRT your first problem: There is a $Self->{CustomerCompany} = {...} section in Kernel/Config/Defaults.pm. Copy that to Kernel/Config.pm and configure it...
Thanks reneeb for your answer, when you were answering I was just trying that solution and I can confirm it's now working
and it has even solved the other problem (don't know how they were linked tough...).

So my problem is now SOLVED.

Thanks again.
Locked