Platform API: Excluding Specific Database Tables When Copying a Tenant
MYOB Acumatica 2025.2.1 introduces the ITablesExcludingProvider interface. With the interface, you can easily specify the tables to exclude when copying a tenant or creating a snapshot.
When to Use the ITablesExcludingProvider Interface
Imagine that you’ve developed and published a customization project for a tenant in your
MYOB Acumatica
instance. You may encounter errors when copying this tenant or trying to restore a snapshot
if a table in the customization project has a unique key that doesn’t include
CompanyID. To avoid this issue, you need to specify that this table
should be excluded
when
the tenant is copied or snapshot is created.
The ITablesExcludingProvider interface helps you do exactly that.
This issue can arise when you work with:
- Commonly customized indexes, such as InventorySearchIndex
- Commonly customized database tables, such as BPEventHistory, SystemEvent, and VisitedRecord
How to Use the ITablesExcludingProvider Interface
To specify tables that should be excluded, you need to implement the
ITablesExcludingProvider interface in the appropriate class of your
extension library and compile it. The following code shows you how to do this. It uses a
class called ExcludedTablesProvider as an example. To make the
ITablesExcludingProvider interface available in this class, the
using PX.BulkInsert directive is used.
using System;
using System.Collections.Generic;
using PX.BulkInsert;
namespace MyCustomization
{
public class ExcludedTablesProvider: ITablesExcludingProvider
{
IEnumerable<string> ITablesExcludingProvider.GetExcludedFromCopyingTables()
{
return new [] { "MyCustomTable"};
}
}
}
The code example above excludes MyCustomTable when the current tenant is
copied or a snapshot is created. The code above implements the
ITablesExcludingProvider interface in the
ExcludedTablesProvider class. In the class, you define the
ITablesExcludingProvider.GetExcludedFromCopyingTables() method, in
which you specify the names of the table that must be excluded as a list.
CompanyID, but you may want to exclude some
sensitive data from this table when you create a snapshot. You should not use the
ITablesExcludingProvider interface for these cases. You should instead
use a custom snapshot configuration to exclude the sensitive data. For examples of these
custom snapshot configurations, see Snapshots: Examples of Sensitive Data Being Excluded from
Snapshots.