Customer DB backend - filter deleted customers?

English! place to talk about development, programming and coding
Post Reply
brandner
Znuny newbie
Posts: 10
Joined: 13 Oct 2015, 20:14
Znuny Version: 5.0.9
Real Name: Tony Brandner

Customer DB backend - filter deleted customers?

Post by brandner »

Enjoying working with OTRS so far.

We are on version 4.0.11 on Ubuntu with multiple customer backend databases. Both are mysql, where one of the backend databases is read-only.

I'm trying to figure out an appropriate strategy to filter the read-only database so that fewer customer records are retrieved. The table contains deleted (archived) data and I don't want them to show up.

Essentially I want to have it use a query like - select * from ourcustomertable where deleted is null

Code: Select all

    # 2. second CustomerDB is the 'address book' functionality
    $Self->{CustomerUser2} = {
        Name   => 'Database Customer Address Book',
        Module => 'Kernel::System::CustomerUser::DB',
        Params => {
            DSN => 'DBI:mysql:database=ourdatabase;host=ourserver;',
            DatabaseUser => 'ouruser',
            DatabasePw => 'ourpassword',
            Table => 'ourcustomertable',
            CaseSensitive => 0,
            ForeignDB => 1,    # set this to 1 if your table does not have create_time, create_by, change_time and change_by fields
        },

        # customer unique id
        CustomerKey => 'customer_id',

        # customer #
        CustomerID => 'email',

        # The last field must always be the email address so that a valid
        #   email address like "John Doe" <john.doe@domain.com> can be constructed from the fields.
        CustomerUserListFields => [ 'first_name', 'last_name', 'email' ],
        CustomerUserSearchFields           => [ 'first_name', 'last_name', 'email' ],
        CustomerUserSearchPrefix           => '*',
        CustomerUserSearchSuffix           => '*',
        CustomerUserSearchListLimit        => 250,
        CustomerUserPostMasterSearchFields => ['email'],
        CustomerUserNameFields             => [ 'first_name', 'last_name' ],
        CustomerUserEmailUniqCheck         => 0,

        # cache time to live in sec. - cache any database queries
        CacheTTL => 60,
        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)
            [ 'UserFirstname',  'Firstname',  'first_name',  1, 1, 'var', '', 0 ],
            [ 'UserLastname',   'Lastname',   'last_name',   1, 1, 'var', '', 0 ],
            [ 'UserLogin',      'Username',   'login',       1, 1, 'var', '', 0 ],
            [ 'UserEmail',      'Email',      'email',       1, 1, 'var', '', 0 ],
            [ 'UserCustomerID', 'CustomerID', 'customer_id', 0, 1, 'var', '', 0 ],
        ],

        # default selections
        Selections => {

        },
    };
Any thoughts on how I could achieve this?
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Customer DB backend - filter deleted customers?

Post by crythias »

Since it's read-only, you could provision a view instead of a table.
https://dev.mysql.com/doc/refman/5.0/en ... -view.html
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Post Reply