Kernel::System::CustomerCompany

NAME

Kernel::System::CustomerCompany – customer company lib

DESCRIPTION

All Customer functions. E.g. to add and update customer companies.

PUBLIC INTERFACE

new()

Don't use the constructor directly, use the ObjectManager instead:

    my $CustomerCompanyObject = $Kernel::OM->Get('Kernel::System::CustomerCompany');

CustomerCompanyAdd()

add a new customer company

    my $ID = $CustomerCompanyObject->CustomerCompanyAdd(
        CustomerID              => 'example.com',
        CustomerCompanyName     => 'New Customer Inc.',
        CustomerCompanyStreet   => '5201 Blue Lagoon Drive',
        CustomerCompanyZIP      => '33126',
        CustomerCompanyCity     => 'Miami',
        CustomerCompanyCountry  => 'USA',
        CustomerCompanyURL      => 'http://www.example.org',
        CustomerCompanyComment  => 'some comment',
        ValidID                 => 1,
        UserID                  => 123,
    );

NOTE: Actual fields accepted by this API call may differ based on CustomerCompany mapping in your system configuration.

CustomerCompanyGet()

get customer company attributes

    my %CustomerCompany = $CustomerCompanyObject->CustomerCompanyGet(
        CustomerID => 123,
        NoSensitive   => 1,       # not required -> 0|1 (default 0)
                                  # returns data without sensitive information
    );

Returns:

    %CustomerCompany = (
        'CustomerCompanyName'    => 'Customer Inc.',
        'CustomerID'             => 'example.com',
        'CustomerCompanyStreet'  => '5201 Blue Lagoon Drive',
        'CustomerCompanyZIP'     => '33126',
        'CustomerCompanyCity'    => 'Miami',
        'CustomerCompanyCountry' => 'United States',
        'CustomerCompanyURL'     => 'http://example.com',
        'CustomerCompanyComment' => 'Some Comments',
        'ValidID'                => '1',
        'CreateTime'             => '2010-10-04 16:35:49',
        'ChangeTime'             => '2010-10-04 16:36:12',
    );

NOTE: Actual fields returned by this API call may differ based on CustomerCompany mapping in your system configuration.

CustomerCompanyUpdate()

update customer company attributes

    $CustomerCompanyObject->CustomerCompanyUpdate(
        CustomerCompanyID       => 'oldexample.com', # required for CustomerCompanyID-update
        CustomerID              => 'example.com',
        CustomerCompanyName     => 'New Customer Inc.',
        CustomerCompanyStreet   => '5201 Blue Lagoon Drive',
        CustomerCompanyZIP      => '33126',
        CustomerCompanyLocation => 'Miami',
        CustomerCompanyCountry  => 'USA',
        CustomerCompanyURL      => 'http://example.com',
        CustomerCompanyComment  => 'some comment',
        ValidID                 => 1,
        UserID                  => 123,
    );

CustomerCompanySourceList()

return customer company source list

    my %List = $CustomerCompanyObject->CustomerCompanySourceList(
        ReadOnly => 0 # optional, 1 returns only RO backends, 0 returns writable, if not passed returns all backends
    );

CustomerCompanyList()

get list of customer companies.

    my %List = $CustomerCompanyObject->CustomerCompanyList();

    my %List = $CustomerCompanyObject->CustomerCompanyList(
        Valid => 0,
        Limit => 0,     # optional, override configured search result limit (0 means unlimited)
    );

    my %List = $CustomerCompanyObject->CustomerCompanyList(
        Search => 'somecompany',
    );

Returns:

    %List = {
        'example.com' => 'example.com Customer Inc.',
        'acme.com'    => 'acme.com Acme, Inc.'
    };

CustomerCompanySearchDetail()

To find customer companies in the system.

The search criteria are logically AND connected. When a list is passed as criteria, the individual members are OR connected. When an undef or a reference to an empty array is passed, then the search criteria is ignored.

Returns either a list, as an arrayref, or a count of found customer company ids. The count of results is returned when the parameter Result = 'COUNT' is passed.

    my $CustomerCompanyIDsRef = $CustomerCompanyObject->CustomerCompanySearchDetail(

        # all search fields possible which are defined in CustomerCompanySearchFields
        CustomerID          => 'example*',                                  # (optional)
        CustomerCompanyName => 'Name*',                                     # (optional)

        # array parameters are used with logical OR operator (all values are possible which
        are defined in the config selection hash for the field)
        CustomerCompanyCountry => [ 'Austria', 'Germany', ],                # (optional)

        # DynamicFields
        #   At least one operator must be specified. Operators will be connected with AND,
        #       values in an operator with OR.
        #   You can also pass more than one argument to an operator: ['value1', 'value2']
        DynamicField_FieldNameX => {
            Equals            => 123,
            Like              => 'value*',                # "equals" operator with wildcard support
            GreaterThan       => '2001-01-01 01:01:01',
            GreaterThanEquals => '2001-01-01 01:01:01',
            SmallerThan       => '2002-02-02 02:02:02',
            SmallerThanEquals => '2002-02-02 02:02:02',
        }

        OrderBy => [ 'CustomerID', 'CustomerCompanyCountry' ],              # (optional)
        # ignored if the result type is 'COUNT'
        # default: [ 'CustomerID' ]
        # (all search fields possible which are defined in CustomerCompanySearchFields)

        # Additional information for OrderBy:
        # The OrderByDirection can be specified for each OrderBy attribute.
        # The pairing is made by the array indices.

        OrderByDirection => [ 'Down', 'Up' ],                               # (optional)
        # ignored if the result type is 'COUNT'
        # (Down | Up) Default: [ 'Down' ]

        Result => 'ARRAY' || 'COUNT',                                       # (optional)
        # default: ARRAY, returns an array of change ids
        # COUNT returns a scalar with the number of found changes

        Limit => 100,                                                       # (optional)
        # ignored if the result type is 'COUNT'

        IncludeUnknownCustomers => 1,                                       # (optional)
    );

Returns:

Result: 'ARRAY'

    @CustomerIDs = ( 1, 2, 3 );

Result: 'COUNT'

    $CustomerIDs = 10;

CustomerCompanySearchFields()

Get a list of defined search fields (optional only the relevant fields for the given source).

    my @SeachFields = $CustomerCompanyObject->CustomerCompanySearchFields(
        Source => 'CustomerCompany', # optional, but important in the CustomerCompanySearchDetail to get the right database fields
        Types => ['Input', 'Selection', 'DynamicField'], # optional
    );

Returns an array of hash references.

    @SeachFields = (
        {
            Name  => 'CustomerID',
            Label => 'CustomerID',
            Type  => 'Input',
        },
        {
            Name           => 'CustomerCompanyCountry',
            Label          => 'Country',
            Type           => 'Selection',
            SelectionsData => {
                'Germany'        => 'Germany',
                'United Kingdom' => 'United Kingdom',
                'United States'  => 'United States',
                ...
            },
        },
        {
            Name          => 'DynamicField_Branch',
            Label         => '',
            Type          => 'DynamicField',
            DatabaseField => 'Branch',
        },
    );

CustomerCompanyFields()

Get a list of the defined fields for the given source.

    my @Fields = $CustomerCompanyObject->CustomerCompanyFields(
        Source => 'CustomerCompany',
        Types => ['Input', 'Selection', 'DynamicField'], # optional
    );

Returns an array of hash references.

   @Fields = (
        {
            Name     => 'CustomerID',
            Label    => 'CustomerID',
            Type     => 'Input',
            Readonly => 0,
            Required => 1,
        },
        {
            Name           => 'CustomerCompanyCountry',
            Label          => 'Country',
            Type           => 'Selection',
            SelectionsData => {
                'Germany'        => 'Germany',
                'United Kingdom' => 'United Kingdom',
                'United States'  => 'United States',
                ...
            },
            Readonly => 0,
            Required => 0,
        },
        {
            Name          => 'DynamicField_Branch',
            Label         => '',
            Type          => 'DynamicField',
            DatabaseField => 'Branch',
            Readonly      => 0,
            Required      => 0,
        },
   );

GetFieldConfig()

This function collect some field config information from the customer user map.

    my %FieldConfig = $CustomerCompanyObject->GetFieldConfig(
        FieldName => 'CustomerCompanyName',
        Source    => 'CustomerCompany', # optional
    );

Returns some field config information:

    my %FieldConfig = (
        Label         => 'Name',
        DatabaseField => 'name',
        StorageType   => 'var',
    );

GetFieldSelections()

This function collect the selections for the given field name, if the field has some selections.

    my %SelectionsData = $CustomerCompanyObject->GetFieldSelections(
        FieldName => 'CustomerCompanyCountry',
        Source    => 'CustomerCompany',       # optional
    );

Returns the selections for the given field name (merged from all sources) or a empty hash:

    my %SelectionData = (
        'Germany'        => 'Germany',
        'United Kingdom' => 'United Kingdom',
        'United States'  => 'United States',
    );

_CustomerUserDataGetDeleteCache()

Deletes the short-lived cache of the method K::S::CustomerUser::CustomerUserDataGet.

    $CustomerCompanyObject->_CustomerUserDataGetDeleteCache();

_UnknownCustomersGet()

Get unknown customers which are not stored in the database (e.g. from an external database).

    $CustomerCompanyObject->_UnknownCustomersGet();
Scroll to Top