---
id: object/codeunit/3902
type: object
title: Codeunit 3902 "Retention Policy Setup"
summary: Codeunit 3902 "Retention Policy Setup" in System Application (System.DataAdministration). 10 public procedures, 8 event subscribers. Present since at least BC23, still in BC30, changed in BC25, BC29.
tier: official
language: en
tags:
  - codeunit
  - system application
versions:
  introduced: null
  last_changed: "29"
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: 312315f7c0140371152b79b18cddb356a30c3e687a9839141181a3e14810200a
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/System%20Application/App/Retention%20Policy/src/Retention%20Policy%20Setup/RetentionPolicySetup.Codeunit.al
    title: src/System Application/App/Retention Policy/src/Retention Policy Setup/RetentionPolicySetup.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
object_type: codeunit
object_id: 3902
name: Retention Policy Setup
namespace: System.DataAdministration
app: System Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "25"
  - "29"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 18
  events: 0
  subscribers: 8
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 2
  called_by: 6
  implements: 0
---

# Codeunit 3902 "Retention Policy Setup"

> Codeunit 3902 "Retention Policy Setup" in System Application (System.DataAdministration). 10 public procedures, 8 event subscribers. Present since at least BC23, still in BC30, changed in BC25, BC29.

System Application · System.DataAdministration · BC23-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/System%20Application/App/Retention%20Policy/src/Retention%20Policy%20Setup/RetentionPolicySetup.Codeunit.al) · facts from BC29

## Properties

| Property | Value |
|---|---|
| Access | Public |

## Event subscriptions

- VerifyRetentionPolicySetupOnbeforeDeleteRetentionPeriod subscribes to Table "Retention Period" OnBeforeDeleteEvent
- VerifyRetentionPolicySetupOnbeforeModifyRetentionPeriod subscribes to Table "Retention Period" OnBeforeModifyEvent
- VerifyRetentionPolicyAllowedTablesOnBeforeInsertRetenPolSetup subscribes to Table "Retention Policy Setup" OnBeforeInsertEvent
- InsertDefaultTableFiltersOnAfterInsertRetenPolSetup subscribes to Table "Retention Policy Setup" OnAfterInsertEvent
- ErrorOnBeforeRenameRetentionPolicySetup subscribes to Table "Retention Policy Setup" OnBeforeRenameEvent
- ErrorOnBeforeRenameRetentionPolicySetupLine subscribes to Table "Retention Policy Setup Line" OnBeforeRenameEvent
- CheckRecordLockedOnRetentionPolicySetupLineOnAfterModify subscribes to Table "Retention Policy Setup Line" OnBeforeModifyEvent
- CheckRecordLockedOnRetentionPolicySetupLineOnAfterDelete subscribes to Table "Retention Policy Setup Line" OnBeforeDeleteEvent

## Procedures

- `SetTableFilterView(var RetentionPolicySetupLine: Record "Retention Policy Setup Line"): Text[2048]`: Use this procedure to open a Filter Page Builder page and store the resulting filter in view format on the retention policy setup line.
- `GetTableFilterView(RetentionPolicySetupLine: Record "Retention Policy Setup Line"): Text`: Use this procedure to get the filter that is stored in a view format on the retention policy setup line.
- `GetTableFilterText(RetentionPolicySetupLine: Record "Retention Policy Setup Line"): Text[2048]`: Use this procedure to get the filter that is stored in a text format on the retention policy setup line.
- `TableIdLookup(TableId: Integer): Integer`: Use this procedure to open a lookup page to select one of the allowed Table Id's.
- `DateFieldNoLookup(TableId: Integer; FieldNo: Integer): Integer`: Use this procedure to open a lookup page to select one of the date or datetime fields for the given table.
- `IsRetentionPolicyEnabled(): Boolean`: This procedure checks whether any retention policies are enabled.
- `IsRetentionPolicyEnabled(TableId: Integer): Boolean`: This procedure checks whether a retention policy is enabled for the given table ID.
- `FindOrCreateRetentionPeriod(RetentionPeriodEnum: Enum "Retention Period Enum"): Code[20]`: Finds or creates a new retention period record for the provided retention period.
- `FindOrCreateRetentionPeriod(RetentionPeriodEnum: Enum "Retention Period Enum"; RetPeriodCalc: DateFormula): Code[20]`: Finds or creates a new retention period record for the provided retention period.
- `FindOrCreateRetentionPeriod(RetentionPeriodCode: Code[20]; RetentionPeriodEnum: Enum "Retention Period Enum"; RetPeriodCalc: DateFormula): Code[20]`: Finds or creates a new retention period record for the provided retention period.

## Calls

From the extracted call graph of BC29 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 3903 "Retention Policy Setup Impl."](../codeunit/3903.md) (15 calls: `CheckRecordLockedOnRetentionPolicySetupLineOnAfterDelete → CheckRecordLockedOnRetentionPolicySetupLine`, `CheckRecordLockedOnRetentionPolicySetupLineOnAfterModify → CheckRecordLockedOnRetentionPolicySetupLine`, `DateFieldNoLookup → DateFieldNoLookup`, …)
- [Codeunit 3908 "Retention Policy Log"](../codeunit/3908.md) (2 calls: `ErrorOnBeforeRenameRetentionPolicySetup → LogError`, `ErrorOnBeforeRenameRetentionPolicySetupLine → LogError`)

## Called by

- [Codeunit 3998 "Retention Policy Scheduler"](../codeunit/3998.md) (3 calls: `CheckRetentionPolicyScheduleOnAfterDelete → IsRetentionPolicyEnabled`, `CheckRetentionPolicyScheduleOnAfterInsert → IsRetentionPolicyEnabled`, `CheckRetentionPolicyScheduleOnAfterModify → IsRetentionPolicyEnabled`)
- [Table 3902 "Retention Policy Setup Line"](../table/3902.md) (3 calls: `GetTableFilterText → GetTableFilterText`, `GetTableFilterView → GetTableFilterView`, `SetTableFilter → SetTableFilterView`)
- [Codeunit 1932 "Scheduled Perf. Profiler Impl."](../codeunit/1932.md) (1 call: `CreateRetentionPolicySetup → FindOrCreateRetentionPeriod`)
- [Codeunit 1933 "Performance Profiler Installer"](../codeunit/1933.md) (1 call: `AddRetentionPolicyAllowedTables → FindOrCreateRetentionPeriod`)
- [Codeunit 3999 "Reten. Pol. Install - BaseApp"](../codeunit/3999.md) (1 call: `FindOrCreateRetentionPeriod → FindOrCreateRetentionPeriod`)
- [Codeunit 8390 "Financial Report Auditing"](../codeunit/8390.md) (1 call: `AddRetentionPolicy → FindOrCreateRetentionPeriod`)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC25, BC29

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC29 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "Retention Policy Setup")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
