bcquality/microsoft/knowledge/privacy/register-owned-log-tables-for-retention-policies.bad.al
Jeremy Vyska 07a171386d Address second review round on retention policy knowledge
- Scope both articles to bc-version [22..]: FindOrCreateRetentionPeriod
  first appears in the 21.1 System Application and OnRefreshAllowedTables
  in 22.
- Reframe the default-setup article as optional guidance; registration
  without a setup is valid. The anti-pattern and review routing now cover
  only false claims that registration alone cleans up data.
- Make all four samples self-contained: declare Contoso Activity Log in
  each, add the Retention Policy Setup permission, and guard the default
  setup on IsAllowedTable.
- Let evaluation overrides list additionalArticles and register both
  retention pairs as extra privacy cases (38 cases, existing IDs unchanged).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 15:46:32 +02:00

33 lines
931 B
AL

table 50567 "Contoso Activity Log"
{
DataClassification = SystemMetadata;
fields
{
field(1; "Entry No."; Integer) { AutoIncrement = true; }
field(2; "Activity"; Text[250]) { }
}
keys
{
key(PK; "Entry No.") { Clustered = true; }
}
}
codeunit 50563 "Contoso Activity Log Cleanup"
{
Access = Internal;
// The log table is never added to the allowed tables, so it cannot appear
// on the Retention Policies page. Cleanup is hard-coded here instead:
// the period is not configurable, the deletion is not written to the
// Retention Policy Log, and an administrator cannot switch it off.
trigger OnRun()
var
ContosoActivityLog: Record "Contoso Activity Log";
begin
ContosoActivityLog.SetFilter(
SystemCreatedAt, '<%1', CreateDateTime(CalcDate('<-30D>', Today()), 0T));
ContosoActivityLog.DeleteAll();
end;
}