Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[releases/25.x] [Email/RetPol] Harden retention policy for Email Inbox setup. #2325

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 5 additions & 24 deletions src/System Application/App/Email/src/EmailInstaller.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ codeunit 1596 "Email Installer"
procedure AddRetentionPolicyAllowedTables()
begin
AddRetentionPolicyAllowedTables(false);
AddRetentionPolicyEmailInboxAllowedTable(false);
CreateRetentionPolicySetup(false);
end;

Expand All @@ -53,26 +52,11 @@ codeunit 1596 "Email Installer"
UpgradeTag.SetUpgradeTag(GetEmailTablesAddedToAllowedListUpgradeTag());
end;

procedure AddRetentionPolicyEmailInboxAllowedTable(ForceUpdate: Boolean)
var
Field: Record Field;
RetenPolAllowedTables: Codeunit "Reten. Pol. Allowed Tables";
UpgradeTag: Codeunit "Upgrade Tag";
IsInitialSetup: Boolean;
begin
IsInitialSetup := not UpgradeTag.HasUpgradeTag(GetEmailInboxAddedToAllowedListUpgradeTag());
if not (IsInitialSetup or ForceUpdate) then
exit;

RetenPolAllowedTables.AddAllowedTable(Database::"Email Inbox", Field.FieldNo(SystemCreatedAt), 2);

if IsInitialSetup then
UpgradeTag.SetUpgradeTag(GetEmailInboxAddedToAllowedListUpgradeTag());
end;

procedure CreateRetentionPolicySetup(ForceUpdate: Boolean)
var
Field: Record Field;
RetentionPolicySetup: Record "Retention Policy Setup";
RetenPolAllowedTables: Codeunit "Reten. Pol. Allowed Tables";
RetentionPolicySetupCU: Codeunit "Retention Policy Setup";
UpgradeTag: Codeunit "Upgrade Tag";
DateFormula: DateFormula;
Expand All @@ -82,6 +66,9 @@ codeunit 1596 "Email Installer"
if not (IsInitialSetup or ForceUpdate) then
exit;

if not RetenPolAllowedTables.AddAllowedTable(Database::"Email Inbox", Field.FieldNo(SystemCreatedAt), 2) then
exit;

RetentionPolicySetup.SetRange("Table Id", Database::"Email Inbox");
if not RetentionPolicySetup.IsEmpty() then
exit;
Expand All @@ -103,11 +90,6 @@ codeunit 1596 "Email Installer"
exit('MS-373161-EmailLogEntryAdded-20201005');
end;

local procedure GetEmailInboxAddedToAllowedListUpgradeTag(): Code[250]
begin
exit('MS-539754-EmailInboxAdded-20240827');
end;

local procedure GetEmailInboxPolicyAddedToAllowedListUpgradeTag(): Code[250]
begin
exit('MS-539754-EmailInboxPolicyAdded-20240827');
Expand All @@ -117,7 +99,6 @@ codeunit 1596 "Email Installer"
local procedure AddAllowedTablesOnRefreshAllowedTables()
begin
AddRetentionPolicyAllowedTables(true);
AddRetentionPolicyEmailInboxAllowedTable(true);
CreateRetentionPolicySetup(true);
end;

Expand Down
Loading