mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-10-07 15:46:55 +01:00
- Scope both articles to bc-version [17..] (retention policies shipped in v17). - Allowed-tables sample: add OnRefreshAllowedTables subscriber with a ForceUpdate path; the upgrade tag now gates one-time setup only. - Default-policy sample: use Retention Policy Setup.FindOrCreateRetentionPeriod instead of a hand-rolled lookup-then-insert that can collide on code. - Anti-pattern now keys on append-only tables rather than table names. - al-privacy-review: add retention-policy tokens and deterministic routing for both articles, with a bounded per-table text search for delete and registration paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
2.1 KiB
AL
71 lines
2.1 KiB
AL
codeunit 50560 "Contoso Reten. Pol. Setup"
|
|
{
|
|
Access = Internal;
|
|
|
|
procedure AddAllowedTables()
|
|
begin
|
|
AddAllowedTables(false);
|
|
end;
|
|
|
|
// ForceUpdate re-registers even after the upgrade tag is set, so the
|
|
// table comes back when an administrator refreshes the allowed tables.
|
|
procedure AddAllowedTables(ForceUpdate: Boolean)
|
|
var
|
|
ContosoActivityLog: Record "Contoso Activity Log";
|
|
RetenPolAllowedTables: Codeunit "Reten. Pol. Allowed Tables";
|
|
UpgradeTag: Codeunit "Upgrade Tag";
|
|
IsInitialSetup: Boolean;
|
|
begin
|
|
IsInitialSetup := not UpgradeTag.HasUpgradeTag(AllowedTableTag());
|
|
if not (IsInitialSetup or ForceUpdate) then
|
|
exit;
|
|
|
|
if not RetenPolAllowedTables.IsAllowedTable(Database::"Contoso Activity Log") then
|
|
RetenPolAllowedTables.AddAllowedTable(
|
|
Database::"Contoso Activity Log",
|
|
ContosoActivityLog.FieldNo(SystemCreatedAt),
|
|
28); // support cases need at least four weeks of log history
|
|
|
|
if IsInitialSetup then
|
|
UpgradeTag.SetUpgradeTag(AllowedTableTag());
|
|
end;
|
|
|
|
local procedure AllowedTableTag(): Code[250]
|
|
begin
|
|
exit('Contoso-ActivityLogAllowedTable-20260910');
|
|
end;
|
|
|
|
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Reten. Pol. Allowed Tables", OnRefreshAllowedTables, '', false, false)]
|
|
local procedure AddAllowedTablesOnRefreshAllowedTables()
|
|
begin
|
|
AddAllowedTables(true);
|
|
end;
|
|
}
|
|
|
|
codeunit 50561 "Contoso Reten. Pol. Install"
|
|
{
|
|
Subtype = Install;
|
|
Access = Internal;
|
|
|
|
trigger OnInstallAppPerCompany()
|
|
var
|
|
ContosoRetenPolSetup: Codeunit "Contoso Reten. Pol. Setup";
|
|
begin
|
|
ContosoRetenPolSetup.AddAllowedTables();
|
|
end;
|
|
}
|
|
|
|
codeunit 50562 "Contoso Reten. Pol. Upgrade"
|
|
{
|
|
Subtype = Upgrade;
|
|
Access = Internal;
|
|
|
|
// Install code does not run on upgrade, so tenants that already have the
|
|
// app get their registration here.
|
|
trigger OnUpgradePerCompany()
|
|
var
|
|
ContosoRetenPolSetup: Codeunit "Contoso Reten. Pol. Setup";
|
|
begin
|
|
ContosoRetenPolSetup.AddAllowedTables();
|
|
end;
|
|
}
|