Company Distribution

Dawid Kaczmarek Updated by Dawid Kaczmarek

Company distribution is an optional selection mechanism in Cepheo Global Data Management (GDM) that lets you control which local companies should receive a given global record values based on a per-record mapping.

When to use

Use company distribution when the target companies depend on the record itself. A typical example is released products: a product should only be pushed to companies where it is released.

How it works (runtime)

Company distribution is configured on a sync criteria line. If enabled, GDM will only consider a record "covered" for a target company when a corresponding row exists in the configured distribution table.

Internally, the validation checks:

  • The source record key (configured as Source relation field) is read from the record being synchronized.
  • The distribution table is queried for a row where:
    • Target relation field equals the source key, and
    • Company distribution field equals the target company.
  • If the row exists, the record can be synchronized to that company; otherwise it is excluded.

The distribution mapping is evaluated in the context of the global company (the legal entity set as GlobalCompany in GDM Parameters).

Configuration

Company distribution is configured on the sync criteria setup (form TGDSyncCriteriaManagement, table TGDSyncCriteriaTable), in the Company distribution section.

Fields
  • Enabled (CompanyDistributionEnabled) — turns company distribution on for the criteria line.
  • Distribution table (CompanyDistributionTable) — name of the mapping table to use.
  • Source relation field (CompanyDistributionSourceRelationField) — field on the source data table used as the key (must uniquely identify the record).
  • Target relation field (CompanyDistributionTargetRelationField) — field on the distribution table that stores the source key.
  • Company distribution field (CompanyDistributionCompanyField) — field on the distribution table that stores the target company (CompanyId/DataAreaId).
Example: Released products (InventTable)

The solution ships with an example distribution table for inventory items: TGDInventTableCompanies (shown in the UI as Item companies).

A typical setup for InventTable is:

  • Enabled: Yes
  • Distribution table: TGDInventTableCompanies
  • Source relation field: ItemId (from InventTable)
  • Target relation field: ItemId (from TGDInventTableCompanies)
  • Company distribution field: RefCompany (from TGDInventTableCompanies)

Maintaining the mapping

You maintain the company distribution mapping by adding or removing rows in the configured distribution table. For the delivered InventTable example, open:

Cepheo GDM menuInquiriesCompany distributionItem companies (menu item TGDInventTableCompanies).

Each row assigns one global record (for example, an item) to one target company.

What happens when you add or remove a row
  • When a mapping row is inserted, the solution calls TGDCompanyUpdateUtility.onCompanyDistributionAdded(...) from the distribution table insert() method (see TGDInventTableCompanies.insert()). If all sync criteria are satisfied, a corresponding TGDCompanyUpdate is created or updated for that company.
  • When a mapping row is deleted, the solution calls TGDCompanyUpdateUtility.onCompanyDistributionDeleted(...) from the distribution table delete() method (see TGDInventTableCompanies.delete()). Existing updates for that record and company are marked for deletion (or removed immediately if already deactivated).

Adding support for more tables (developer guide)

To add company distribution support for another data table, you need (A) a distribution table that stores the mapping, and (B) a small integration that triggers creation or removal of company updates when the mapping changes.

1) Create a distribution table

Design requirements:

  • A field that stores the source record key (the value you will configure as Target relation field).
  • A field that stores the target company (the value you will configure as Company distribution field).
  • A unique index across (source key, company) to prevent duplicates.

Tip: Use TGDInventTableCompanies as a reference implementation.

2) Provide a way to maintain the mapping

The mapping can be maintained via a simple list form (as done for TGDInventTableCompanies) and/or via a Data Management entity for bulk load.

3) Trigger company update creation or removal on mapping changes

The simplest approach is to override insert() and delete() on the distribution table and call TGDCompanyUpdateUtility (same pattern as TGDInventTableCompanies).

// Pseudocode (pattern)
public void insert()
{
super();
TGDCompanyUpdateUtility::construct()
.onCompanyDistributionAdded(
TGDTable::findTableId(tableNum(<SourceTable>)),
<SourceTable>::find(<key>),
<targetCompanyId>);
}

public void delete()
{
// Cache what you need before super()
<SourceTable> src = <SourceTable>::find(<key>);
CompanyId companyId = <targetCompanyId>;
super();
TGDCompanyUpdateUtility::construct()
.onCompanyDistributionDeleted(
TGDTable::findTableId(tableNum(<SourceTable>)),
src,
companyId);
}

Notes:

  • The _globalRecord passed to the utility must be a record from the global (master) company.
  • If your distribution table is company-specific (DataAreaId), store its rows in the global company.
  • If you do not trigger the utility on changes, the mapping will only take effect after running "Recreate company updates".
4) Configure the sync criteria line

On the sync criteria line for your source table, set the Company distribution fields so the engine can join:

  • Source relation field = key field on the source table
  • Target relation field = key field on the distribution table
  • Company distribution field = company field on the distribution table

Troubleshooting

  • If nothing is distributed, verify the sync criteria line is active and Company distribution is enabled.
  • If records are distributed to too many companies, check that the distribution table does not contain unintended rows.
  • If a mapping row exists but no updates are created, validate that the field names configured in sync criteria match the actual table fields.

How did we do?

Selection management

Global data management setup

Contact