From c03e3b04426db09e14585c810b958fda490a433e Mon Sep 17 00:00:00 2001 From: Bert Verbeek <71499421+Bertverbeek4PS@users.noreply.github.com> Date: Sat, 10 Dec 2022 04:40:17 +0100 Subject: [PATCH] [#51] Tables getting bulkier with time (#56) * Error on obsolete fields added * Added obsolete State Field * Only obsolete removed fields cannot be exported * Added obsolete field help text * Added API page * Reset for all selected tables * Option to refresh the tablefields. * Removed commit Option to refresh the tablefields. * Removed commit Reset for all selected tables * Seperate into two API pages * Added fields enabled and multi-company export and removed functions enabled and disable * Added two tables to retention policy * Removed api pages from other pull request * Fixed comments * Changed file names * Small fixes after comments * Few changes after comments * Small change after rebranche * Incremented version * Version fix and unused variables removed * Added event OnAfterInitializeCompany * Merge branch main --- README.md | 1 + businessCentral/app.json | 4 ++-- .../src/ADLSEExecution.Codeunit.al | 2 ++ .../src/ADLSEInstaller.codeunit.al | 18 ++++++++++++++++ businessCentral/src/ADLSEUpgrade.Codeunit.al | 21 +++++++++++++++++++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 businessCentral/src/ADLSEInstaller.codeunit.al create mode 100644 businessCentral/src/ADLSEUpgrade.Codeunit.al diff --git a/README.md b/README.md index 6bdbe5c..6702b97 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ More details: Pull request | Changes --------------- | --- +[56](https://github.com/microsoft/bc2adls/pull/56) | The table ADLSE Run has now been added to the retention policy so that the logs for the executions can be cleared periodically, thus taking up less space in the database. [55](https://github.com/microsoft/bc2adls/pull/55) | A much awaited request to allow the BC extension to read from the replica database saves up resources that can otherwise be dedicated to normal ERP operations, has now been implemented. This change is dependent on the version 21 of the application. [59](https://github.com/microsoft/bc2adls/pull/59) | The default rounding principles caused the consolidated data to have a maximum of two decimal places even though the data in the `deltas` may have had higher decimal precision. Added an applied trait to all decimal fields so that they account for up to 5 decimal places. [54](https://github.com/microsoft/bc2adls/pull/54) | Fixes irregularities on the System Audit fields. (1) Very old records do not appear in the lake sometimes because the `SystemCreatedAt` field is set to null. This field is now artificaly initialized to a date so that it appears in the lake, and (2) The `SystemID` field may be repeated over different records belonging to different companies in the same table. Thus, the uniqueness contraint has been fixed. diff --git a/businessCentral/app.json b/businessCentral/app.json index 5fbd0ad..03525f1 100644 --- a/businessCentral/app.json +++ b/businessCentral/app.json @@ -4,7 +4,7 @@ "publisher": "The bc2adls team, Microsoft Denmark", "brief": "Sync data from Business Central to the Azure storage", "description": "Exports data in chosen tables to the Azure Data Lake and keeps it in sync by incremental updates. Before you use this tool, please read the SUPPORT.md file at https://github.com/microsoft/bc2adls.", - "version": "1.3.2.2", + "version": "1.3.2.3", "privacyStatement": "https://go.microsoft.com/fwlink/?LinkId=724009", "EULA": "https://go.microsoft.com/fwlink/?linkid=2009120", "help": "https://go.microsoft.com/fwlink/?LinkId=724011", @@ -24,7 +24,7 @@ "idRanges": [ { "from": 82560, - "to": 82570 + "to": 82572 } ], "target": "Cloud", diff --git a/businessCentral/src/ADLSEExecution.Codeunit.al b/businessCentral/src/ADLSEExecution.Codeunit.al index b5a1f96..64a26e9 100644 --- a/businessCentral/src/ADLSEExecution.Codeunit.al +++ b/businessCentral/src/ADLSEExecution.Codeunit.al @@ -27,12 +27,14 @@ codeunit 82569 "ADLSE Execution" ADLSESetup: Codeunit "ADLSE Setup"; ADLSECommunication: Codeunit "ADLSE Communication"; ADLSESessionManager: Codeunit "ADLSE Session Manager"; + ADLSEExecution: Codeunit "ADLSE Execution"; Counter: Integer; Started: Integer; begin ADLSESetup.CheckSetup(ADLSESetupRec); EmitTelemetry := ADLSESetupRec."Emit telemetry"; ADLSECurrentSession.CleanupSessions(); + ADLSEExecution.ClearTrackedDeletedRecords(); ADLSECommunication.SetupBlobStorage(); ADLSESessionManager.Init(); diff --git a/businessCentral/src/ADLSEInstaller.codeunit.al b/businessCentral/src/ADLSEInstaller.codeunit.al new file mode 100644 index 0000000..dad17dc --- /dev/null +++ b/businessCentral/src/ADLSEInstaller.codeunit.al @@ -0,0 +1,18 @@ +codeunit 82571 "ADLSE Installer" +{ + Subtype = Install; + Access = Internal; + + trigger OnInstallAppPerCompany() + begin + AddAllowedTables(); + end; + + procedure AddAllowedTables() + var + RetenPolAllowedTables: Codeunit "Reten. Pol. Allowed Tables"; + ADLSERun: Record "ADLSE Run"; + begin + RetenPolAllowedTables.AddAllowedTable(Database::"ADLSE Run", ADLSERun.FieldNo(SystemModifiedAt)); + end; +} \ No newline at end of file diff --git a/businessCentral/src/ADLSEUpgrade.Codeunit.al b/businessCentral/src/ADLSEUpgrade.Codeunit.al new file mode 100644 index 0000000..a0f7d35 --- /dev/null +++ b/businessCentral/src/ADLSEUpgrade.Codeunit.al @@ -0,0 +1,21 @@ +codeunit 82572 "ADLSE Upgrade" +{ + Subtype = Upgrade; + Access = Internal; + + trigger OnUpgradePerCompany() + var + ADLSEInstaller: Codeunit "ADLSE Installer"; + UpgradeTag: Codeunit "Upgrade Tag"; + begin + if UpgradeTag.HasUpgradeTag(GetRetenPolLogEntryAddedUpgradeTag()) then + exit; + ADLSEInstaller.AddAllowedTables(); + UpgradeTag.SetUpgradeTag(GetRetenPolLogEntryAddedUpgradeTag()); + end; + + local procedure GetRetenPolLogEntryAddedUpgradeTag(): Code[250] + begin + exit('MS-334067-ADLSERetenPolLogEntryAdded-20221028'); + end; +} \ No newline at end of file