diff --git a/src/System Application/App/File System/README.md b/src/System Application/App/File System/README.md
new file mode 100644
index 0000000000..b8a84d99c0
--- /dev/null
+++ b/src/System Application/App/File System/README.md
@@ -0,0 +1,7 @@
+# File System Module for Business Central
+Provides an API that lets you connect file system accounts to Business Central so that people can access files outside BC.
+
+## Main Components
+
+### File Account
+A file account holds the information needed to access a file system from Business Central.
diff --git a/src/System Application/App/File System/app.json b/src/System Application/App/File System/app.json
new file mode 100644
index 0000000000..63dffae392
--- /dev/null
+++ b/src/System Application/App/File System/app.json
@@ -0,0 +1,70 @@
+{
+ "id": "c9c54414-80c3-4cc9-98c6-589158882774",
+ "name": "File System",
+ "publisher": "Microsoft",
+ "brief": "Access external file systems",
+ "description": "Enables access to external file systems from Business Central.",
+ "version": "26.0.0.0",
+ "privacyStatement": "https://go.microsoft.com/fwlink/?linkid=724009",
+ "EULA": "https://go.microsoft.com/fwlink/?linkid=2009120",
+ "help": "https://go.microsoft.com/fwlink/?linkid=2103698",
+ "url": "https://go.microsoft.com/fwlink/?linkid=724011",
+ "logo": "",
+ "dependencies": [
+ {
+ "id": "7e3b999e-1182-45d2-8b82-d5127ddba9b2",
+ "name": "DotNet Aliases",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ },
+ {
+ "id": "872fe7e8-9893-40ae-ab94-c123ed30fdbd",
+ "name": "Extension Management",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ },
+ {
+ "id": "de35f591-7216-4e60-8be1-1911d71a7fc2",
+ "name": "Telemetry",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ },
+ {
+ "id": "0846d207-5dec-4c1b-afd8-6a25e1e14b9d",
+ "name": "Base64 Convert",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ },
+ {
+ "id": "a4584a53-9345-458a-af20-d1df2fab7bd8",
+ "name": "Confirm Management",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ },
+ {
+ "id": "e31ad830-3d46-472e-afeb-1d3d35247943",
+ "name": "BLOB Storage",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ }
+ ],
+ "internalsVisibleTo": [
+ {
+ "id": "f188754b-3ffb-443a-9507-f5fbdae3af2c",
+ "name": "File System Test Library",
+ "publisher": "Microsoft"
+ }
+ ],
+ "screenshots": [
+
+ ],
+ "platform": "26.0.0.0",
+ "idRanges": [
+ {
+ "from": 9450,
+ "to": 9459
+ }
+ ],
+ "target": "OnPrem",
+ "contextSensitiveHelpUrl": "https://go.microsoft.com/fwlink/?linkid=2134520"
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/permissions/FileSystemAdmin.PermissionSet.al b/src/System Application/App/File System/permissions/FileSystemAdmin.PermissionSet.al
new file mode 100644
index 0000000000..b3006b9973
--- /dev/null
+++ b/src/System Application/App/File System/permissions/FileSystemAdmin.PermissionSet.al
@@ -0,0 +1,22 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+permissionset 9450 "File System - Admin"
+{
+ Access = Public;
+ Assignable = true;
+ Caption = 'File System - Admin';
+
+ IncludedPermissionSets = "File System - Edit";
+
+ Permissions =
+ tabledata "File System Connector" = RIMD,
+ tabledata "File System Connector Logo" = RIMD,
+ tabledata "File Account Scenario" = RIMD,
+ tabledata "File Scenario" = RIMD,
+ tabledata "File Account Content" = RIMD;
+}
diff --git a/src/System Application/App/File System/permissions/FileSystemEdit.PermissionSet.al b/src/System Application/App/File System/permissions/FileSystemEdit.PermissionSet.al
new file mode 100644
index 0000000000..5b9761bbb3
--- /dev/null
+++ b/src/System Application/App/File System/permissions/FileSystemEdit.PermissionSet.al
@@ -0,0 +1,20 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+using System.Environment;
+
+permissionset 9453 "File System - Edit"
+{
+ Access = Public;
+ Assignable = false;
+ Caption = 'File System - Edit';
+
+ IncludedPermissionSets = "File System - Read";
+
+ Permissions = tabledata "File System Connector Logo" = imd,
+ tabledata "Tenant Media" = imd;
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/permissions/FileSystemObjects.PermissionSet.al b/src/System Application/App/File System/permissions/FileSystemObjects.PermissionSet.al
new file mode 100644
index 0000000000..2fec87ddd6
--- /dev/null
+++ b/src/System Application/App/File System/permissions/FileSystemObjects.PermissionSet.al
@@ -0,0 +1,15 @@
+namespace System.FileSystem;
+
+permissionset 9452 "File System - Objects"
+{
+ Access = Internal;
+ Assignable = false;
+
+ Permissions =
+ table "File Account" = X,
+ table "File System Connector" = X,
+ table "File System Connector Logo" = X,
+ table "File Account Content" = X,
+ table "File Account Scenario" = X,
+ table "File Scenario" = X;
+}
diff --git a/src/System Application/App/File System/permissions/FileSystemRead.PermissionSet.al b/src/System Application/App/File System/permissions/FileSystemRead.PermissionSet.al
new file mode 100644
index 0000000000..8bd52ab4e8
--- /dev/null
+++ b/src/System Application/App/File System/permissions/FileSystemRead.PermissionSet.al
@@ -0,0 +1,23 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+using System.Environment;
+
+permissionset 9451 "File System - Read"
+{
+ Access = Internal;
+ Assignable = false;
+ IncludedPermissionSets = "File System - Objects";
+
+ Permissions =
+ tabledata "File System Connector" = r,
+ tabledata "File System Connector Logo" = r,
+ tabledata "File Account Scenario" = r,
+ tabledata "File Scenario" = r,
+ tabledata "File Account Content" = r,
+ tabledata Media = r; // This permission is required by File System Account Wizard
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Account/FileAccount.Codeunit.al b/src/System Application/App/File System/src/Account/FileAccount.Codeunit.al
new file mode 100644
index 0000000000..5165b56b2b
--- /dev/null
+++ b/src/System Application/App/File System/src/Account/FileAccount.Codeunit.al
@@ -0,0 +1,48 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+///
+/// Provides functionality to work with file accounts.
+///
+
+codeunit 9450 "File Account"
+{
+ Access = Public;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+
+ ///
+ /// Gets all of the file accounts registered in Business Central.
+ ///
+ /// Flag, used to determine whether to load the logos for the accounts.
+ /// Out parameter holding the file accounts.
+ procedure GetAllAccounts(LoadLogos: Boolean; var TempFileAccount: Record "File Account" temporary)
+ begin
+ FileAccountImpl.GetAllAccounts(LoadLogos, TempFileAccount);
+ end;
+
+ ///
+ /// Gets all of the file accounts registered in Business Central.
+ ///
+ /// Out parameter holding the file accounts.
+ procedure GetAllAccounts(var TempFileAccount: Record "File Account" temporary)
+ begin
+ FileAccountImpl.GetAllAccounts(false, TempFileAccount);
+ end;
+
+ ///
+ /// Checks if there is at least one file account registered in Business Central.
+ ///
+ /// True if there is any account registered in the system, otherwise - false.
+ procedure IsAnyAccountRegistered(): Boolean
+ begin
+ exit(FileAccountImpl.IsAnyAccountRegistered());
+ end;
+
+ var
+ FileAccountImpl: Codeunit "File Account Impl.";
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Account/FileAccount.Table.al b/src/System Application/App/File System/src/Account/FileAccount.Table.al
new file mode 100644
index 0000000000..c149061766
--- /dev/null
+++ b/src/System Application/App/File System/src/Account/FileAccount.Table.al
@@ -0,0 +1,55 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+///
+/// A common representation of a file account.
+///
+table 9450 "File Account"
+{
+ Extensible = false;
+ TableType = Temporary;
+
+ fields
+ {
+ field(1; "Account Id"; Guid)
+ {
+ DataClassification = SystemMetadata;
+ }
+ field(2; Name; Text[250])
+ {
+ DataClassification = SystemMetadata; // Field only in Memory
+ }
+ field(4; Connector; Enum "File System Connector")
+ {
+ DataClassification = SystemMetadata;
+ }
+ field(5; Logo; Media)
+ {
+ Access = Internal;
+ DataClassification = SystemMetadata;
+ }
+ }
+
+ keys
+ {
+ key(PK; "Account Id", Connector)
+ {
+ Clustered = true;
+ }
+ key(Name; Name)
+ {
+ Description = 'Used for sorting';
+ }
+ }
+
+ fieldgroups
+ {
+ fieldgroup(Brick; Logo, Name)
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Account/FileAccountImpl.Codeunit.al b/src/System Application/App/File System/src/Account/FileAccountImpl.Codeunit.al
new file mode 100644
index 0000000000..1bc722a651
--- /dev/null
+++ b/src/System Application/App/File System/src/Account/FileAccountImpl.Codeunit.al
@@ -0,0 +1,227 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+using System.Text;
+using System.Utilities;
+
+codeunit 9451 "File Account Impl."
+{
+ Access = Internal;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+ Permissions = tabledata "File System Connector Logo" = rimd,
+ tabledata "File Scenario" = imd;
+
+ procedure GetAllAccounts(LoadLogos: Boolean; var TempFileAccount: Record "File Account" temporary)
+ var
+ FileAccounts: Record "File Account";
+ FileSystemConnector: Interface "File System Connector";
+ Connector: Enum "File System Connector";
+ begin
+ TempFileAccount.Reset();
+ TempFileAccount.DeleteAll();
+
+ foreach Connector in Connector.Ordinals do begin
+ FileSystemConnector := Connector;
+
+ FileAccounts.DeleteAll();
+ FileSystemConnector.GetAccounts(FileAccounts);
+
+ if FileAccounts.FindSet() then
+ repeat
+ TempFileAccount := FileAccounts;
+ TempFileAccount.Connector := Connector;
+
+ if LoadLogos then
+ ImportLogo(TempFileAccount, Connector);
+
+ TempFileAccount.Insert();
+ until FileAccounts.Next() = 0;
+ end;
+
+ // Sort by account name
+ TempFileAccount.SetCurrentKey(Name);
+ end;
+
+ procedure DeleteAccounts(var FileAccountsToDelete: Record "File Account")
+ var
+ CurrentDefaultFileAccount: Record "File Account";
+ ConfirmManagement: Codeunit "Confirm Management";
+ FileScenario: Codeunit "File Scenario";
+ FileSystemConnector: Interface "File System Connector";
+ begin
+ CheckPermissions();
+
+ if not ConfirmManagement.GetResponseOrDefault(ConfirmDeleteQst, true) then
+ exit;
+
+ if not FileAccountsToDelete.FindSet() then
+ exit;
+
+ // Get the current default account to track if it was deleted
+ FileScenario.GetDefaultFileAccount(CurrentDefaultFileAccount);
+
+ // Delete all selected accounts
+ repeat
+ // Check to validate that the connector is still installed
+ // The connector could have been uninstalled by another user/session
+ if IsValidConnector(FileAccountsToDelete.Connector) then begin
+ FileSystemConnector := FileAccountsToDelete.Connector;
+ FileSystemConnector.DeleteAccount(FileAccountsToDelete."Account Id");
+ end;
+ until FileAccountsToDelete.Next() = 0;
+
+ DefaultAccountDeletion(CurrentDefaultFileAccount."Account Id", CurrentDefaultFileAccount.Connector);
+ end;
+
+ local procedure DefaultAccountDeletion(CurrentDefaultAccountId: Guid; Connector: Enum "File System Connector")
+ var
+ AllFileAccounts: Record "File Account";
+ NewDefaultFileAccount: Record "File Account";
+ FileScenario: Codeunit "File Scenario";
+ begin
+ GetAllAccounts(false, AllFileAccounts);
+
+ if AllFileAccounts.IsEmpty() then
+ exit; //All of the accounts were deleted, nothing to do
+
+ if AllFileAccounts.Get(CurrentDefaultAccountId, Connector) then
+ exit; // The default account was not deleted or it never existed
+
+ // In case there's only one account, set it as default
+ if AllFileAccounts.Count() = 1 then begin
+ MakeDefault(AllFileAccounts);
+ exit;
+ end;
+
+ Commit(); // Commit the accounts deletion in order to prompt for a new default account
+ if PromptNewDefaultAccountChoice(NewDefaultFileAccount) then
+ MakeDefault(NewDefaultFileAccount)
+ else
+ FileScenario.UnassignScenario(Enum::"File Scenario"::Default); // remove the default scenario as it is pointing to a non-existent account
+ end;
+
+ local procedure PromptNewDefaultAccountChoice(var NewDefaultFileAccount: Record "File Account"): Boolean
+ var
+ FileAccountsPage: Page "File Accounts";
+ begin
+ FileAccountsPage.LookupMode(true);
+ FileAccountsPage.EnableLookupMode();
+ FileAccountsPage.Caption(ChooseNewDefaultTxt);
+ if FileAccountsPage.RunModal() = Action::LookupOK then begin
+ FileAccountsPage.GetAccount(NewDefaultFileAccount);
+ exit(true);
+ end;
+
+ exit(false);
+ end;
+
+ local procedure ImportLogo(var FileAccount: Record "File Account"; FileSystemConnector: Interface "File System Connector")
+ var
+ FileSystemConnectorLogo: Record "File System Connector Logo";
+ Base64Convert: Codeunit "Base64 Convert";
+ TempBlob: Codeunit "Temp Blob";
+ InStream: InStream;
+ ConnectorLogoDescriptionTxt: Label '%1 Logo', Locked = true;
+ OutStream: OutStream;
+ ConnectorLogoBase64: Text;
+ begin
+ ConnectorLogoBase64 := FileSystemConnector.GetLogoAsBase64();
+
+ if ConnectorLogoBase64 = '' then
+ exit;
+ if not FileSystemConnectorLogo.Get(FileAccount.Connector) then begin
+ TempBlob.CreateOutStream(OutStream);
+ Base64Convert.FromBase64(ConnectorLogoBase64, OutStream);
+ TempBlob.CreateInStream(InStream);
+ FileSystemConnectorLogo.Init();
+ FileSystemConnectorLogo.Connector := FileAccount.Connector;
+ FileSystemConnectorLogo.Logo.ImportStream(InStream, StrSubstNo(ConnectorLogoDescriptionTxt, FileAccount.Connector));
+ if FileSystemConnectorLogo.Insert() then;
+ end;
+ FileAccount.Logo := FileSystemConnectorLogo.Logo;
+ end;
+
+ procedure IsAnyAccountRegistered(): Boolean
+ var
+ FileAccount: Record "File Account";
+ begin
+ GetAllAccounts(false, FileAccount);
+
+ exit(not FileAccount.IsEmpty());
+ end;
+
+ procedure IsUserFileAdmin(): Boolean
+ var
+ FileScenario: Record "File Scenario";
+ begin
+ exit(FileScenario.WritePermission());
+ end;
+
+ procedure FindAllConnectors(var FileConnector: Record "File System Connector")
+ var
+ FileConnectorLogo: Record "File System Connector Logo";
+ ConnectorInterface: Interface "File System Connector";
+ FileSystemConnector: Enum "File System Connector";
+ begin
+ foreach FileSystemConnector in Enum::"File System Connector".Ordinals() do begin
+ ConnectorInterface := FileSystemConnector;
+ FileConnector.Connector := FileSystemConnector;
+ FileConnector.Description := ConnectorInterface.GetDescription();
+ if FileConnectorLogo.Get(FileConnector.Connector) then
+ FileConnector.Logo := FileConnectorLogo.Logo;
+ FileConnector.Insert();
+ end;
+ end;
+
+ procedure IsValidConnector(Connector: Enum "File System Connector"): Boolean
+ begin
+ exit("File System Connector".Ordinals().Contains(Connector.AsInteger()));
+ end;
+
+ procedure MakeDefault(var FileAccount: Record "File Account")
+ var
+ FileScenario: Codeunit "File Scenario";
+ begin
+ CheckPermissions();
+
+ if IsNullGuid(FileAccount."Account Id") then
+ exit;
+
+ FileScenario.SetDefaultFileAccount(FileAccount);
+ end;
+
+ procedure BrowseAccount(var FileAccount: Record "File Account")
+ var
+ FileAccountBrowser: Page "File Account Browser";
+ begin
+ CheckPermissions();
+
+ if IsNullGuid(FileAccount."Account Id") then
+ exit;
+
+ FileAccountBrowser.SetFileAccount(FileAccount);
+ FileAccountBrowser.BrowseFileAccount('');
+ FileAccountBrowser.Run();
+ end;
+
+ procedure CheckPermissions()
+ begin
+ if not IsUserFileAdmin() then
+ Error(CannotManageSetupErr);
+ end;
+
+ [InternalEvent(false)]
+ procedure OnAfterSetSelectionFilter(var FileAccount: Record "File Account")
+ begin
+ end;
+
+ var
+ CannotManageSetupErr: Label 'Your user account does not give you permission to set up file. Please contact your administrator.';
+ ChooseNewDefaultTxt: Label 'Choose a Default Account';
+ ConfirmDeleteQst: Label 'Go ahead and delete?';
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Account/FileAccountWizard.Page.al b/src/System Application/App/File System/src/Account/FileAccountWizard.Page.al
new file mode 100644
index 0000000000..100812085f
--- /dev/null
+++ b/src/System Application/App/File System/src/Account/FileAccountWizard.Page.al
@@ -0,0 +1,493 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+using System.Apps;
+using System.Environment;
+using System.Telemetry;
+
+///
+/// Step by step guide for adding a new file account in Business Central
+///
+page 9451 "File Account Wizard"
+{
+ PageType = NavigatePage;
+ ApplicationArea = All;
+ UsageCategory = Administration;
+ Caption = 'Set Up File';
+ SourceTable = "File System Connector";
+ SourceTableTemporary = true;
+ InsertAllowed = false;
+ ModifyAllowed = false;
+ DeleteAllowed = false;
+ Editable = true;
+ ShowFilter = false;
+ LinksAllowed = false;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+ Permissions = tabledata Media = r,
+ tabledata "Media Resources" = r;
+
+ layout
+ {
+ area(Content)
+ {
+ group(Done)
+ {
+ Editable = false;
+ ShowCaption = false;
+ Visible = not DoneVisible and TopBannerVisible;
+ field(NotDoneIcon; MediaResourcesStandard."Media Reference")
+ {
+ Editable = false;
+ ShowCaption = false;
+ ToolTip = ' ';
+ Caption = ' ';
+ }
+ }
+ group(NotDone)
+ {
+ Editable = false;
+ ShowCaption = false;
+ Visible = DoneVisible and TopBannerVisible;
+ field(DoneIcon; MediaResourcesDone."Media Reference")
+ {
+ Editable = false;
+ ShowCaption = false;
+ ToolTip = ' ';
+ Caption = ' ';
+ }
+ }
+
+ group(Header)
+ {
+ ShowCaption = false;
+ Visible = WelcomeVisible;
+
+ group(HeaderText)
+ {
+ Caption = 'Welcome to file in Business Central';
+ InstructionalText = 'Make file communications easier by connecting file accounts to Business Central. For example, store sales quotes and orders pdfs without opening an file app.';
+ }
+ field(LearnMoreHeader; LearnMoreTok)
+ {
+ Editable = false;
+ ShowCaption = false;
+ Caption = ' ';
+ ToolTip = 'View information about how to set up the file capabilities.';
+
+ trigger OnDrillDown()
+ begin
+ Hyperlink(LearnMoreURLTxt);
+ end;
+ }
+ group(Privacy)
+ {
+ Caption = 'Privacy notice';
+ InstructionalText = 'By adding a file account you acknowledge that the file provider might be able to access the data you send in files from Business Central.';
+ }
+ group(GetStartedText)
+ {
+ Caption = 'Let''s go!';
+ InstructionalText = 'Choose Next to get started.';
+ }
+ }
+
+ group(ConnectorHeader)
+ {
+ ShowCaption = false;
+ Visible = ChooseConnectorVisible and ConnectorsAvailable;
+
+ label(UsageWarning)
+ {
+ Caption = 'Use caution when adding file accounts. Depending on your setup, accounts can be available to all users.';
+ }
+ }
+
+ group(ConnectorsGroup)
+ {
+ Visible = ChooseConnectorVisible and ConnectorsAvailable;
+ label("Specify the type of file account to add")
+ {
+ Caption = 'Specify the type of file account to add';
+ }
+ repeater(Connectors)
+ {
+ ShowCaption = false;
+ Visible = ChooseConnectorVisible and ConnectorsAvailable;
+ FreezeColumn = Name;
+ Editable = false;
+
+ field(Logo; Rec.Logo)
+ {
+ Caption = ' ';
+ Editable = false;
+ Visible = ChooseConnectorVisible;
+ ToolTip = 'Specifies the type of the account you want to create.';
+ ShowCaption = false;
+ Width = 1;
+ }
+ field(Name; Rec.Connector)
+ {
+ Caption = 'Account Type';
+ ToolTip = 'Specifies the type of the account you want to create.';
+ Editable = false;
+ }
+ field(Details; Rec.Description)
+ {
+ Caption = 'Details';
+ ToolTip = 'Specifies more details about the account type.';
+ Editable = false;
+ Width = 50;
+ }
+ }
+ }
+
+ group(NoConnectrosAvailableGroup)
+ {
+ Visible = ChooseConnectorVisible and not ConnectorsAvailable;
+ label(NoConnectorsAvailable)
+ {
+ Caption = 'There are no file apps available. To use this feature you must install an file app.';
+ }
+ label(NoConnectorsAvailable2)
+ {
+ Caption = 'File apps are available in Extension Management and AppSource.';
+ }
+ field(ExtensionManagement; ExtensionManagementTok)
+ {
+ Editable = false;
+ ShowCaption = false;
+ Caption = ' ';
+ ToolTip = 'Navigate to Extension Management page.';
+
+ trigger OnDrillDown()
+ begin
+ Page.Run(Page::"Extension Management");
+ end;
+ }
+ field(AppSource; AppSourceTok)
+ {
+ Editable = false;
+ ShowCaption = false;
+ Visible = AppSourceAvailable;
+ Caption = ' ';
+ ToolTip = 'Navigate to AppSource.';
+
+ trigger OnDrillDown()
+ begin
+ AppSource := AppSource.Create();
+ AppSource.ShowAppSource();
+ end;
+ }
+ label(NoConnectorsAvailable3)
+ {
+ Caption = 'View a list of the available file apps';
+ }
+ field(LearnMore; LearnMoreTok)
+ {
+ Editable = false;
+ ShowCaption = false;
+ Caption = ' ';
+ ToolTip = 'View information about how to set up the file capabilities.';
+
+ trigger OnDrillDown()
+ begin
+ Hyperlink(LearnMoreURLTxt);
+ end;
+ }
+ }
+
+ group(LastPage)
+ {
+ Visible = DoneVisible;
+
+ group(AllSet)
+ {
+ Caption = 'Congratulations!';
+ InstructionalText = 'You have successfully added the file account. To check that it is working, send a test file.';
+ }
+ group(Account)
+ {
+ Caption = 'Account';
+ field(NameField; RegisteredAccount.Name)
+ {
+ Editable = false;
+ Caption = 'Name';
+ ToolTip = 'Specifies the name of the account registered.';
+ }
+ }
+ group(Default)
+ {
+ Caption = '';
+
+ field(DefaultField; SetAsDefault)
+ {
+ Editable = true;
+ Enabled = true;
+ Caption = 'Set as default';
+ ToolTip = 'Specifies the the account for all scenarios.';
+ }
+ }
+ }
+ }
+ }
+
+ actions
+ {
+ area(Processing)
+ {
+ action(Cancel)
+ {
+ Visible = CancelActionVisible;
+ Caption = 'Cancel';
+ ToolTip = 'Cancel';
+ InFooterBar = true;
+ Image = Cancel;
+
+ trigger OnAction()
+ begin
+ CurrPage.Close();
+ end;
+ }
+
+ action(Back)
+ {
+ Visible = BackActionVisible;
+ Enabled = BackActionEnabled;
+ Caption = 'Back';
+ ToolTip = 'Back';
+ InFooterBar = true;
+ Image = PreviousRecord;
+
+ trigger OnAction()
+ begin
+ NextStep(true);
+ end;
+ }
+
+ action(Next)
+ {
+ Visible = NextActionVisible;
+ Enabled = NextActionEnabled;
+ Caption = 'Next';
+ ToolTip = 'Next';
+ InFooterBar = true;
+ Image = NextRecord;
+
+ trigger OnAction()
+ begin
+ NextStep(false);
+ end;
+ }
+
+ action(Finish)
+ {
+ Visible = FinishActionVisible;
+ Caption = 'Finish';
+ ToolTip = 'Finish';
+ InFooterBar = true;
+ Image = NextRecord;
+
+ trigger OnAction()
+ var
+ FileAccountImpl: Codeunit "File Account Impl.";
+ begin
+ if SetAsDefault then
+ FileAccountImpl.MakeDefault(RegisteredAccount);
+
+ CurrPage.Close();
+ end;
+ }
+ }
+ }
+
+ trigger OnOpenPage()
+ begin
+ StartTime := CurrentDateTime();
+ end;
+
+ trigger OnQueryClosePage(CloseAction: Action): Boolean
+ var
+ DurationAsInt: Integer;
+ begin
+ DurationAsInt := CurrentDateTime() - StartTime;
+ if Step = Step::Done then
+ Session.LogMessage('0000CTK', StrSubstNo(AccountCreationSuccessfullyCompletedDurationLbl, DurationAsInt), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', FileCategoryLbl)
+ else
+ Session.LogMessage('0000CTL', StrSubstNo(AccountCreationFailureDurationLbl, DurationAsInt), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', FileCategoryLbl);
+ end;
+
+ trigger OnInit()
+ var
+ DefaultAccount: Record "File Account";
+ FileAccountImpl: Codeunit "File Account Impl.";
+ FileScenario: Codeunit "File Scenario";
+ begin
+ FileAccountImpl.CheckPermissions();
+
+ Step := Step::Welcome;
+ SetDefaultControls();
+ ShowWelcomeStep();
+
+ FileAccountImpl.FindAllConnectors(Rec);
+
+ FileRateLimitDisplay := NoLimitTxt;
+
+ if not FileScenario.GetDefaultFileAccount(DefaultAccount) then
+ SetAsDefault := true;
+
+ ConnectorsAvailable := Rec.FindFirst(); // Set the focus on the first record
+ AppSourceAvailable := AppSource.IsAvailable();
+ LoadTopBanners();
+ end;
+
+ local procedure NextStep(Backwards: Boolean)
+ begin
+ if Backwards then
+ Step -= 1
+ else
+ Step += 1;
+
+ SetDefaultControls();
+
+ case Step of
+ Step::Welcome:
+ ShowWelcomeStep();
+ Step::"Choose Connector":
+ ShowChooseConnectorStep();
+ Step::"Register Account":
+ ShowRegisterAccountStep();
+ Step::Done:
+ ShowDoneStep();
+ end;
+ end;
+
+ local procedure ShowWelcomeStep()
+ begin
+ WelcomeVisible := true;
+ BackActionEnabled := false;
+ end;
+
+ local procedure ShowChooseConnectorStep()
+ begin
+ if not ConnectorsAvailable then
+ NextActionEnabled := false;
+
+ ChooseConnectorVisible := true;
+ end;
+
+ local procedure ShowRegisterAccountStep()
+ var
+ FeatureTelemetry: Codeunit "Feature Telemetry";
+ Telemetry: Codeunit Telemetry;
+ AccountWasRegistered: Boolean;
+ ConnectorSucceeded: Boolean;
+ CustomDimensions: Dictionary of [Text, Text];
+ CTHLbl: Label '%1 account has been setup.', Locked = true;
+ CTILbl: Label '%1 account has failed to setup. Error: %2', Locked = true;
+ begin
+ ConnectorSucceeded := TryRegisterAccount(AccountWasRegistered);
+ CustomDimensions.Add('Category', FileCategoryLbl);
+
+ if AccountWasRegistered then begin
+ FeatureTelemetry.LogUptake('0000CTF', 'File Access', Enum::"Feature Uptake Status"::"Set up");
+ Telemetry.LogMessage('0000CTH', StrSubstNo(CTHLbl, Rec.Connector), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, CustomDimensions);
+ NextStep(false);
+ end else begin
+ Telemetry.LogMessage('0000CTI', StrSubstNo(CTILbl, Rec.Connector, GetLastErrorCallStack()), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, CustomDimensions);
+ NextStep(true);
+ end;
+
+ if not ConnectorSucceeded then
+ Error(GetLastErrorText());
+ end;
+
+ [TryFunction]
+ local procedure TryRegisterAccount(var AccountWasRegistered: Boolean)
+ var
+ FileAccountImpl: Codeunit "File Account Impl.";
+ FileConnector: Interface "File System Connector";
+ begin
+ // Check to validate that the connector is still installed
+ // The connector could have been uninstalled by another user/session
+ if not FileAccountImpl.IsValidConnector(Rec.Connector) then
+ Error(FileConnectorHasBeenUninstalledMsg);
+
+ FileConnector := Rec.Connector;
+
+ ClearLastError();
+ AccountWasRegistered := FileConnector.RegisterAccount(RegisteredAccount);
+ RegisteredAccount.Connector := Rec.Connector;
+ end;
+
+ local procedure ShowDoneStep()
+ begin
+ DoneVisible := true;
+ BackActionVisible := false;
+ NextActionVisible := false;
+ CancelActionVisible := false;
+ FinishActionVisible := true;
+ end;
+
+ local procedure SetDefaultControls()
+ begin
+ // Actions
+ BackActionVisible := true;
+ BackActionEnabled := true;
+ NextActionVisible := true;
+ NextActionEnabled := true;
+ CancelActionVisible := true;
+ FinishActionVisible := false;
+
+ // Groups
+ WelcomeVisible := false;
+ ChooseConnectorVisible := false;
+ DoneVisible := false;
+ end;
+
+ local procedure LoadTopBanners()
+ var
+ AssistedSetupLogoTok: Label 'ASSISTEDSETUP-NOTEXT-400PX.PNG', Locked = true;
+ begin
+ if MediaResourcesStandard.Get(AssistedSetupLogoTok) and
+ MediaResourcesDone.Get(AssistedSetupLogoTok) and (CurrentClientType() = ClientType::Web)
+ then
+ TopBannerVisible := MediaResourcesDone."Media Reference".HasValue();
+ end;
+
+ var
+ RegisteredAccount: Record "File Account";
+ MediaResourcesStandard: Record "Media Resources";
+ MediaResourcesDone: Record "Media Resources";
+ [RunOnClient]
+ AppSource: DotNet AppSource;
+ Step: Option Welcome,"Choose Connector","Register Account",Done;
+ AppSourceTok: Label 'AppSource';
+ ExtensionManagementTok: Label 'Extension Management';
+ FileCategoryLbl: Label 'File', Locked = true;
+ LearnMoreURLTxt: Label 'https://go.microsoft.com/fwlink/?linkid=2134520', Locked = true; //FIXME
+ LearnMoreTok: Label 'Learn more';
+ NoLimitTxt: Label 'No limit';
+ AccountCreationSuccessfullyCompletedDurationLbl: Label 'Successful creation of account completed. Duration: %1 milliseconds.', Comment = '%1 - Duration', Locked = true;
+ AccountCreationFailureDurationLbl: Label 'Creation of account failed. Duration: %1 milliseconds.', Comment = '%1 - Duration', Locked = true;
+ FileConnectorHasBeenUninstalledMsg: Label 'The selected file extension has been uninstalled. You must reinstall the extension to add an account with it.';
+ AppSourceAvailable: Boolean;
+ TopBannerVisible: Boolean;
+ BackActionVisible: Boolean;
+ BackActionEnabled: Boolean;
+ NextActionVisible: Boolean;
+ NextActionEnabled: Boolean;
+ CancelActionVisible: Boolean;
+ FinishActionVisible: Boolean;
+ WelcomeVisible: Boolean;
+ ChooseConnectorVisible: Boolean;
+ DoneVisible: Boolean;
+ ConnectorsAvailable: Boolean;
+ SetAsDefault: Boolean;
+ StartTime: DateTime;
+ FileRateLimitDisplay: Text[250];
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Account/FileAccounts.Page.al b/src/System Application/App/File System/src/Account/FileAccounts.Page.al
new file mode 100644
index 0000000000..d4a1c8ab39
--- /dev/null
+++ b/src/System Application/App/File System/src/Account/FileAccounts.Page.al
@@ -0,0 +1,322 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+using System.Telemetry;
+
+///
+/// Lists all of the registered file accounts
+///
+page 9450 "File Accounts"
+{
+ PageType = List;
+ Caption = 'File Accounts';
+ ApplicationArea = All;
+ UsageCategory = Administration;
+ SourceTable = "File Account";
+ SourceTableTemporary = true;
+ InsertAllowed = false;
+ ModifyAllowed = false;
+ DeleteAllowed = false;
+ Editable = false;
+ ShowFilter = false;
+ LinksAllowed = false;
+ RefreshOnActivate = true;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+
+ layout
+ {
+ area(Content)
+ {
+ repeater(Accounts)
+ {
+ FreezeColumn = NameField;
+ field(LogoField; Rec.Logo)
+ {
+ ShowCaption = false;
+ Caption = ' ';
+ ToolTip = 'Specifies the logo for the type of file account.';
+ Width = 1;
+ }
+ field(NameField; Rec.Name)
+ {
+ ToolTip = 'Specifies the name of the account.';
+ Visible = not IsInLookupMode;
+
+ trigger OnDrillDown()
+ begin
+ ShowAccountInformation();
+ end;
+ }
+ field(NameFieldLookup; Rec.Name)
+ {
+ ToolTip = 'Specifies the name of the account.';
+ Visible = IsInLookupMode;
+ }
+ field(DefaultField; DefaultTxt)
+ {
+ Caption = 'Default';
+ ToolTip = 'Specifies whether the file account will be used for all scenarios for which an account is not specified. You must have a default file account, even if you have only one account.';
+ Visible = not IsInLookupMode;
+ }
+ field(FileConnector; Rec.Connector)
+ {
+ ToolTip = 'Specifies the type of file extension that the account is added to.';
+ Visible = false;
+ }
+ }
+ }
+
+ area(FactBoxes)
+ {
+ part(Scenarios; "File Scenarios FactBox")
+ {
+ Caption = 'File Scenarios';
+ SubPageLink = "Account Id" = field("Account Id"), Connector = field(Connector), Scenario = filter(<> 0); // Do not show Default scenario
+ }
+ }
+ }
+
+ actions
+ {
+ area(Creation)
+ {
+ action(View)
+ {
+ Image = View;
+ ToolTip = 'View settings for the file account.';
+ ShortcutKey = return;
+ Visible = false;
+
+ trigger OnAction()
+ begin
+ ShowAccountInformation();
+ end;
+ }
+
+ action(AddAccount)
+ {
+ Image = Add;
+ Caption = 'Add a file account';
+ ToolTip = 'Opens a File Account Wizard setup page in order to add a file account.';
+ Visible = (not IsInLookupMode) and CanUserManageFileSetup;
+
+ trigger OnAction()
+ begin
+ Page.RunModal(Page::"File Account Wizard");
+
+ UpdateFileAccounts();
+ end;
+ }
+ }
+ area(Processing)
+ {
+ action(MakeDefault)
+ {
+ Image = Default;
+ Caption = 'Set as default';
+ ToolTip = 'Mark the selected file account as the default account. This account will be used for all scenarios for which an account is not specified.';
+ Visible = (not IsInLookupMode) and CanUserManageFileSetup;
+ Scope = Repeater;
+ Enabled = not IsDefault;
+
+ trigger OnAction()
+ begin
+ FileAccountImpl.MakeDefault(Rec);
+
+ UpdateAccounts := true;
+ CurrPage.Update(false);
+ end;
+ }
+ action(BrowseAccount)
+ {
+ Image = SelectField;
+ Caption = 'Browse Account';
+ ToolTip = 'Opens a File Browser and shows the content of the selected account.';
+ Visible = (not IsInLookupMode) and CanUserManageFileSetup;
+ Scope = Repeater;
+
+ trigger OnAction()
+ begin
+ FileAccountImpl.BrowseAccount(Rec);
+
+ UpdateAccounts := true;
+ CurrPage.Update(false);
+ end;
+ }
+
+ action(Delete)
+ {
+ Image = Delete;
+ Caption = 'Delete file account';
+ ToolTip = 'Delete the file account.';
+ Visible = (not IsInLookupMode) and CanUserManageFileSetup;
+ Scope = Repeater;
+
+ trigger OnAction()
+ begin
+ CurrPage.SetSelectionFilter(Rec);
+ FileAccountImpl.OnAfterSetSelectionFilter(Rec);
+
+ FileAccountImpl.DeleteAccounts(Rec);
+
+ UpdateFileAccounts();
+ end;
+ }
+ }
+ area(Navigation)
+ {
+ action(FileScenarioSetup)
+ {
+ Image = Answers;
+ Caption = 'File Scenarios';
+ ToolTip = 'Assign scenarios to the file accounts.';
+ Visible = not IsInLookupMode;
+
+ trigger OnAction()
+ var
+ FileScenarioSetup: Page "File Scenario Setup";
+ begin
+ FileScenarioSetup.SetFileAccountId(Rec."Account Id", Rec.Connector);
+ FileScenarioSetup.Run();
+ end;
+ }
+ }
+ area(Promoted)
+ {
+ group(Category_New)
+ {
+ Caption = 'New';
+
+ actionref(AddAccount_Promoted; AddAccount)
+ {
+ }
+ }
+ group(Category_Process)
+ {
+ Caption = 'Process';
+
+ actionref(MakeDefault_Promoted; MakeDefault)
+ {
+ }
+ actionref(BrowseAccount_Promoted; BrowseAccount)
+ {
+ }
+ actionref(Delete_Promoted; Delete)
+ {
+ }
+ }
+
+ group(Category_Category4)
+ {
+ Caption = 'Navigate';
+
+ actionref(FileScenarioSetup_Promoted; FileScenarioSetup)
+ {
+ }
+ }
+ }
+ }
+
+ trigger OnOpenPage()
+ var
+ FeatureTelemetry: Codeunit "Feature Telemetry";
+ begin
+ FeatureTelemetry.LogUptake('0000CTA', 'File System', Enum::"Feature Uptake Status"::Discovered);
+ CanUserManageFileSetup := FileAccountImpl.IsUserFileAdmin();
+ Rec.SetCurrentKey("Account Id", Connector);
+ UpdateFileAccounts();
+ end;
+
+ trigger OnAfterGetRecord()
+ begin
+ // Updating the accounts is done via OnAfterGetRecord in the cases when an account was changed from the corresponding connector's page
+ if UpdateAccounts then begin
+ UpdateAccounts := false;
+ UpdateFileAccounts();
+ end;
+
+ DefaultTxt := '';
+
+ IsDefault := DefaultFileAccount."Account Id" = Rec."Account Id";
+ if IsDefault then
+ DefaultTxt := '✓';
+ end;
+
+ local procedure UpdateFileAccounts()
+ var
+ FileAccount: Codeunit "File Account";
+ FileScenario: Codeunit "File Scenario";
+ IsSelected: Boolean;
+ SelectedAccountId: Guid;
+ begin
+ // We need this code block to maintain the same selected record.
+ SelectedAccountId := Rec."Account Id";
+ IsSelected := not IsNullGuid(SelectedAccountId);
+
+ FileAccount.GetAllAccounts(true, Rec); // Refresh the file accounts
+ FileScenario.GetDefaultFileAccount(DefaultFileAccount); // Refresh the default file account
+
+ if IsSelected then begin
+ Rec."Account Id" := SelectedAccountId;
+ if Rec.Find() then;
+ end else
+ if Rec.FindFirst() then;
+
+ CurrPage.Update(false);
+ end;
+
+ local procedure ShowAccountInformation()
+ var
+ Connector: Interface "File System Connector";
+ begin
+ UpdateAccounts := true;
+
+ if not FileAccountImpl.IsValidConnector(Rec.Connector) then
+ Error(FileConnectorHasBeenUninstalledMsg);
+
+ Connector := Rec.Connector;
+ Connector.ShowAccountInformation(Rec."Account Id");
+ end;
+
+ ///
+ /// Gets the selected file account.
+ ///
+ /// The selected file account
+ procedure GetAccount(var FileAccount: Record "File Account")
+ begin
+ FileAccount := Rec;
+ end;
+
+ ///
+ /// Sets a file account to be selected.
+ ///
+ /// The file account to be initially selected on the page
+ procedure SetAccount(var FileAccount: Record "File Account")
+ begin
+ Rec := FileAccount;
+ end;
+
+ ///
+ /// Enables the lookup mode on the page.
+ ///
+ procedure EnableLookupMode()
+ begin
+ IsInLookupMode := true;
+ CurrPage.LookupMode(true);
+ end;
+
+ var
+ DefaultFileAccount: Record "File Account";
+ FileAccountImpl: Codeunit "File Account Impl.";
+ CanUserManageFileSetup: Boolean;
+ IsDefault: Boolean;
+ IsInLookupMode: Boolean;
+ UpdateAccounts: Boolean;
+ FileConnectorHasBeenUninstalledMsg: Label 'The selected file extension has been uninstalled. To view information about the file account, you must reinstall the extension.';
+ DefaultTxt: Text;
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Connector/FileSystemConnector.Enum.al b/src/System Application/App/File System/src/Connector/FileSystemConnector.Enum.al
new file mode 100644
index 0000000000..9052f72749
--- /dev/null
+++ b/src/System Application/App/File System/src/Connector/FileSystemConnector.Enum.al
@@ -0,0 +1,14 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+///
+/// Enum that holds all of the available file connectors.
+///
+enum 9450 "File System Connector" implements "File System Connector"
+{
+ Extensible = true;
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Connector/FileSystemConnector.Interface.al b/src/System Application/App/File System/src/Connector/FileSystemConnector.Interface.al
new file mode 100644
index 0000000000..7dbfd39386
--- /dev/null
+++ b/src/System Application/App/File System/src/Connector/FileSystemConnector.Interface.al
@@ -0,0 +1,140 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+///
+/// A File System Connector interface used to create file accounts and handle external files.
+///
+interface "File System Connector"
+{
+ ///
+ /// Gets a List of Files stored on the provided account.
+ ///
+ /// The file account ID which is used to get the file.
+ /// The file path to list.
+ /// Defines the pagination data.
+ /// A list with all files stored in the path.
+ procedure ListFiles(AccountId: Guid; Path: Text; FilePaginationData: Codeunit "File Pagination Data"; var FileAccountContent: Record "File Account Content" temporary);
+
+ ///
+ /// Gets a file from the provided account.
+ ///
+ /// The file account ID which is used to get the file.
+ /// The file path inside the file account.
+ /// The Stream were the file is read to.
+ procedure GetFile(AccountId: Guid; Path: Text; Stream: InStream);
+
+ ///
+ /// Gets a file to the provided account.
+ ///
+ /// The file account ID which is used to send out the file.
+ /// The file path inside the file account.
+ /// The Stream were the file is read from.
+ procedure CreateFile(AccountId: Guid; Path: Text; Stream: InStream);
+
+ ///
+ /// Copies as file inside the provided account.
+ ///
+ /// The file account ID which is used to send out the file.
+ /// The source file path.
+ /// The target file path.
+ procedure CopyFile(AccountId: Guid; SourcePath: Text; TargetPath: Text);
+
+ ///
+ /// Move as file inside the provided account.
+ ///
+ /// The file account ID which is used to send out the file.
+ /// The source file path.
+ /// The target file path.
+ procedure MoveFile(AccountId: Guid; SourcePath: Text; TargetPath: Text);
+
+ ///
+ /// Checks if a file exists on the provided account.
+ ///
+ /// The file account ID which is used to send out the file.
+ /// The file path inside the file account.
+ /// Returns true if the file exists
+ procedure FileExists(AccountId: Guid; Path: Text): Boolean;
+
+ ///
+ /// Deletes a file exists on the provided account.
+ ///
+ /// The file account ID which is used to send out the file.
+ /// The file path inside the file account.
+ procedure DeleteFile(AccountId: Guid; Path: Text);
+
+ ///
+ /// Gets a List of Directories stored on the provided account.
+ ///
+ /// The file account ID which is used to get the file.
+ /// The file path to list.
+ /// Defines the pagination data.
+ /// A list with all directories stored in the path.
+ procedure ListDirectories(AccountId: Guid; Path: Text; FilePaginationData: Codeunit "File Pagination Data"; var FileAccountContent: Record "File Account Content" temporary);
+
+ ///
+ /// Creates a directory on the provided account.
+ ///
+ /// The directory path inside the file account.
+ /// The file account ID which is used to send out the file.
+ procedure CreateDirectory(AccountId: Guid; Path: Text);
+
+ ///
+ /// Checks if a directory exists on the provided account.
+ ///
+ /// The file account ID which is used to send out the file.
+ /// The directory path inside the file account.
+ /// Returns true if the directory exists
+ procedure DirectoryExists(AccountId: Guid; Path: Text): Boolean;
+
+ ///
+ /// Deletes a directory exists on the provided account.
+ ///
+ /// The file account ID which is used to send out the file.
+ /// The directory path inside the file account.
+ procedure DeleteDirectory(AccountId: Guid; Path: Text);
+
+ ///
+ /// Gets the file accounts registered for the connector.
+ ///
+ /// Out variable that holds the registered file accounts for the connector.
+ procedure GetAccounts(var Accounts: Record "File Account");
+
+ ///
+ /// Shows the information for a file account.
+ ///
+ /// The ID of the file account
+ procedure ShowAccountInformation(AccountId: Guid);
+
+ ///
+ /// Registers a file account for the connector.
+ ///
+ /// The out parameter must hold the account ID of the added account.
+ /// Out parameter with the details of the registered Account.
+ /// True if an account was registered.
+ procedure RegisterAccount(var FileAccount: Record "File Account"): Boolean
+
+ ///
+ /// Deletes a file account for the connector.
+ ///
+ /// The ID of the file account
+ /// True if an account was deleted.
+ procedure DeleteAccount(AccountId: Guid): Boolean
+
+ ///
+ /// Provides a custom logo for the connector that shows in the Setup File Account Guide.
+ ///
+ /// Base64 encoded image.
+ /// The recommended image size is 128x128.
+ /// The logo of the connector is Base64 format
+ procedure GetLogoAsBase64(): Text;
+
+ ///
+ /// Provides a more detailed description of the connector.
+ ///
+ /// A more detailed description of the connector.
+ procedure GetDescription(): Text[250];
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Connector/FileSystemConnector.Table.al b/src/System Application/App/File System/src/Connector/FileSystemConnector.Table.al
new file mode 100644
index 0000000000..1de21c827c
--- /dev/null
+++ b/src/System Application/App/File System/src/Connector/FileSystemConnector.Table.al
@@ -0,0 +1,38 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+table 9451 "File System Connector"
+{
+ TableType = Temporary;
+ Access = Internal;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+
+ fields
+ {
+ field(1; Connector; Enum "File System Connector")
+ {
+ DataClassification = SystemMetadata;
+ }
+ field(2; Logo; Media)
+ {
+ DataClassification = SystemMetadata;
+ }
+ field(3; Description; Text[250])
+ {
+ DataClassification = SystemMetadata;
+ }
+ }
+
+ keys
+ {
+ key(PK; Connector)
+ {
+ Clustered = true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Connector/FileSystemConnectorLogo.Table.al b/src/System Application/App/File System/src/Connector/FileSystemConnectorLogo.Table.al
new file mode 100644
index 0000000000..1437980cb1
--- /dev/null
+++ b/src/System Application/App/File System/src/Connector/FileSystemConnectorLogo.Table.al
@@ -0,0 +1,34 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+table 9452 "File System Connector Logo"
+{
+ DataClassification = SystemMetadata;
+ Access = Internal;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+
+ fields
+ {
+ field(1; Connector; Enum "File System Connector")
+ {
+ DataClassification = SystemMetadata;
+ }
+ field(2; Logo; Media)
+ {
+ DataClassification = CustomerContent;
+ }
+ }
+
+ keys
+ {
+ key(PK; Connector)
+ {
+ Clustered = true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/FileSystem/FileSystem.Codeunit.al b/src/System Application/App/File System/src/FileSystem/FileSystem.Codeunit.al
new file mode 100644
index 0000000000..e7d839d6cb
--- /dev/null
+++ b/src/System Application/App/File System/src/FileSystem/FileSystem.Codeunit.al
@@ -0,0 +1,252 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+codeunit 9454 "File System"
+{
+ InherentPermissions = X;
+ InherentEntitlements = X;
+
+ var
+ FileSystemImpl: Codeunit "File System Impl.";
+
+ ///
+ /// Initialized the File System for the given scenario.
+ ///
+ /// File Scenario to use.
+ procedure Initialize(Scenario: Enum "File Scenario")
+ begin
+ FileSystemImpl.Initialize(Scenario);
+ end;
+
+ ///
+ /// Initialized the File System for the give file account.
+ ///
+ /// File Account to use.
+ procedure Initialize(FileAccount: Record "File Account")
+ begin
+ FileSystemImpl.Initialize(FileAccount);
+ end;
+
+ ///
+ /// List all files from the given path.
+ ///
+ /// Folder to list
+ /// Defines the pagination data.
+ /// File account content.
+ procedure ListFiles(Path: Text; FilePaginationData: Codeunit "File Pagination Data"; var FileAccountContent: Record "File Account Content" temporary)
+ begin
+ FileSystemImpl.ListFiles(Path, FilePaginationData, FileAccountContent);
+ end;
+
+ ///
+ /// Retrieves a file from the file account.
+ ///
+ /// File Path to open.
+ /// Stream which contains the file content.
+ [TryFunction]
+ procedure GetFile(Path: Text; Stream: InStream)
+ begin
+ FileSystemImpl.GetFile(Path, Stream);
+ end;
+
+ ///
+ /// Stores a file in to the file account.
+ ///
+ /// File Path inside the file account.
+ /// Stream to store.
+ [TryFunction]
+ procedure CreateFile(Path: Text; Stream: InStream)
+ begin
+ FileSystemImpl.CreateFile(Path, Stream);
+ end;
+
+ ///
+ /// Copies a file in the file account.
+ ///
+ /// Source path of the file.
+ /// Target Path of the file copy.
+ [TryFunction]
+ procedure CopyFile(SourcePath: Text; TargetPath: Text)
+ begin
+ FileSystemImpl.CopyFile(SourcePath, TargetPath);
+ end;
+
+ ///
+ /// Moves a file in the file account.
+ ///
+ /// Source path of the file.
+ /// Target Path of the file.
+ [TryFunction]
+ procedure MoveFile(SourcePath: Text; TargetPath: Text)
+ begin
+ FileSystemImpl.MoveFile(SourcePath, TargetPath);
+ end;
+
+ ///
+ /// Checks if a specific file exists in the file account.
+ ///
+ /// File path to check.
+ /// Returns true if the file exists.
+ procedure FileExists(Path: Text): Boolean
+ begin
+ exit(FileSystemImpl.FileExists(Path));
+ end;
+
+ ///
+ /// Deletes a file from the file account.
+ ///
+ /// File path of the file to delete.
+ [TryFunction]
+ procedure DeleteFile(Path: Text)
+ begin
+ FileSystemImpl.DeleteFile(Path);
+ end;
+
+ ///
+ /// List all directories from the given path.
+ ///
+ /// Folder to list
+ /// Defines the pagination data.
+ /// File account content.
+ [TryFunction]
+ procedure ListDirectories(Path: Text; FilePaginationData: Codeunit "File Pagination Data"; var FileAccountContent: Record "File Account Content" temporary)
+ begin
+ FileSystemImpl.ListDirectories(Path, FilePaginationData, FileAccountContent);
+ end;
+
+ ///
+ /// Creates a directory in the file account.
+ ///
+ /// Path of the new Directory to create.
+ [TryFunction]
+ procedure CreateDirectory(Path: Text)
+ begin
+ FileSystemImpl.CreateDirectory(Path);
+ end;
+
+ ///
+ /// Checks if a specific directory exists in the file account.
+ ///
+ /// Path of the directory to check.
+ /// Returns true if directory exists.
+ procedure DirectoryExists(Path: Text): Boolean
+ begin
+ exit(FileSystemImpl.DirectoryExists(Path));
+ end;
+
+ ///
+ /// Deletes a directory from the file account.
+ ///
+ /// Directory to remove.
+ [TryFunction]
+ procedure DeleteDirectory(Path: Text)
+ begin
+ FileSystemImpl.DeleteDirectory(Path);
+ end;
+
+ ///
+ /// Combines to paths together.
+ ///
+ /// First part to combine.
+ /// Second part to combine.
+ /// Correctly combined path.
+ procedure CombinePath(Path: Text; ChildPath: Text): Text
+ begin
+ exit(FileSystemImpl.CombinePath(Path, ChildPath));
+ end;
+
+ ///
+ /// Gets the Parent Path of the given path.
+ ///
+ /// File or directory path.
+ /// The parent of the specified path.
+ procedure GetParentPath(Path: Text): Text
+ begin
+ exit(FileSystemImpl.GetParentPath(Path));
+ end;
+
+ ///
+ /// Opens a folder selection dialog.
+ ///
+ /// Start path of the dialog.
+ /// Returns the selected Folder.
+ procedure SelectFolderUI(Path: Text): Text
+ var
+ DefaultSelectFolderUILbl: Label 'Select a folder';
+ begin
+ exit(SelectFolderUI(Path, DefaultSelectFolderUILbl));
+ end;
+
+ ///
+ /// Opens a folder selection dialog.
+ ///
+ /// Start path of the dialog.
+ /// Title of the selection dialog.
+ /// Returns the selected Folder.
+ procedure SelectFolderUI(Path: Text; DialogTitle: Text): Text
+ begin
+ exit(FileSystemImpl.SelectFolderUI(Path, DialogTitle));
+ end;
+
+ ///
+ /// Opens a select file dialog.
+ ///
+ /// Start path.
+ /// A filter string that applies only on files not on folders.
+ /// Returns the path of the selected file.
+ procedure SelectFileUI(Path: Text; FileFilter: Text): Text
+ var
+ DefaultSelectFileUILbl: Label 'Select a file';
+ begin
+ exit(SelectFileUI(Path, FileFilter, DefaultSelectFileUILbl));
+ end;
+
+ ///
+ /// Opens a select file dialog.
+ ///
+ /// Start path of the dialog.
+ /// A filter string that applies only on files not on folders.
+ /// Title of the selection dialog.
+ /// Returns the path of the selected file.
+ procedure SelectFileUI(Path: Text; FileFilter: Text; DialogTitle: Text): Text
+ begin
+ exit(FileSystemImpl.SelectFileUI(Path, FileFilter, DialogTitle));
+ end;
+
+ ///
+ /// Opens a save to dialog.
+ ///
+ /// Start path of the dialog.
+ /// The file extension without dot (like pdf or txt).
+ /// Returns the selected file path.
+ procedure SaveFileUI(Path: Text; FileExtension: Text): Text
+ var
+ DefaultSaveFileUITitleLbl: Label 'Save as';
+ begin
+ exit(SaveFileUI(Path, FileExtension, DefaultSaveFileUITitleLbl));
+ end;
+
+ ///
+ /// Opens a save to dialog.
+ ///
+ /// Start path of the dialog.
+ /// The file extension without dot (like pdf or txt).
+ /// Title of the selection dialog.
+ /// Returns the selected file path.
+ procedure SaveFileUI(Path: Text; FileExtension: Text; DialogTitle: Text): Text
+ begin
+ exit(FileSystemImpl.SaveFileUI(Path, FileExtension, DialogTitle));
+ end;
+
+ ///
+ /// Opens a File Browser
+ ///
+ procedure BrowseAccount()
+ begin
+ FileSystemImpl.BrowseAccount();
+ end;
+}
diff --git a/src/System Application/App/File System/src/FileSystem/FileSystemImpl.Codeunit.al b/src/System Application/App/File System/src/FileSystem/FileSystemImpl.Codeunit.al
new file mode 100644
index 0000000000..df08d1d5be
--- /dev/null
+++ b/src/System Application/App/File System/src/FileSystem/FileSystemImpl.Codeunit.al
@@ -0,0 +1,249 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+codeunit 9455 "File System Impl."
+{
+ Access = Internal;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+
+ var
+ CurrFileAccount: Record "File Account";
+ FileSystemConnector: Interface "File System Connector";
+ IsInitialized: Boolean;
+
+ procedure Initialize(Scenario: Enum "File Scenario")
+ var
+ FileAccount: Record "File Account";
+ FileScenarioMgt: Codeunit "File Scenario";
+ NoFileAccountFoundErr: Label 'No default file account defined.';
+ begin
+ if not FileScenarioMgt.GetFileAccount(Scenario, FileAccount) then
+ Error(NoFileAccountFoundErr);
+
+ Initialize(FileAccount);
+ end;
+
+ procedure Initialize(FileAccount: Record "File Account")
+ begin
+ CurrFileAccount := FileAccount;
+ FileSystemConnector := FileAccount.Connector;
+ IsInitialized := true;
+ end;
+
+ procedure ListFiles(Path: Text; FilePaginationData: Codeunit "File Pagination Data"; var FileAccountContent: Record "File Account Content" temporary)
+ begin
+ CheckPath(Path);
+ CheckInitialization();
+ FileSystemConnector.ListFiles(CurrFileAccount."Account Id", Path, FilePaginationData, FileAccountContent);
+ end;
+
+ procedure GetFile(Path: Text; Stream: InStream)
+ begin
+ CheckPath(Path);
+ CheckInitialization();
+ FileSystemConnector.GetFile(CurrFileAccount."Account Id", Path, Stream);
+ end;
+
+ procedure CreateFile(Path: Text; Stream: InStream)
+ begin
+ CheckPath(Path);
+ CheckInitialization();
+ FileSystemConnector.CreateFile(CurrFileAccount."Account Id", Path, Stream);
+ end;
+
+ procedure CopyFile(SourcePath: Text; TargetPath: Text)
+ begin
+ CheckPath(SourcePath);
+ CheckPath(TargetPath);
+ CheckInitialization();
+ FileSystemConnector.CopyFile(CurrFileAccount."Account Id", SourcePath, TargetPath);
+ end;
+
+ procedure MoveFile(SourcePath: Text; TargetPath: Text)
+ begin
+ CheckPath(SourcePath);
+ CheckPath(TargetPath);
+ CheckInitialization();
+ FileSystemConnector.MoveFile(CurrFileAccount."Account Id", SourcePath, TargetPath);
+ end;
+
+ procedure FileExists(Path: Text): Boolean
+ begin
+ CheckPath(Path);
+ CheckInitialization();
+ exit(FileSystemConnector.FileExists(CurrFileAccount."Account Id", Path));
+ end;
+
+ procedure DeleteFile(Path: Text)
+ begin
+ CheckPath(Path);
+ CheckInitialization();
+ FileSystemConnector.DeleteFile(CurrFileAccount."Account Id", Path);
+ end;
+
+ procedure ListDirectories(Path: Text; FilePaginationData: Codeunit "File Pagination Data"; var FileAccountContent: Record "File Account Content" temporary)
+ begin
+ CheckPath(Path);
+ CheckInitialization();
+ FileSystemConnector.ListDirectories(CurrFileAccount."Account Id", Path, FilePaginationData, FileAccountContent);
+ end;
+
+ procedure CreateDirectory(Path: Text)
+ begin
+ CheckPath(Path);
+ CheckInitialization();
+ FileSystemConnector.CreateDirectory(CurrFileAccount."Account Id", Path);
+ end;
+
+ procedure DirectoryExists(Path: Text): Boolean
+ begin
+ CheckPath(Path);
+ CheckInitialization();
+ exit(FileSystemConnector.DirectoryExists(CurrFileAccount."Account Id", Path));
+ end;
+
+ procedure DeleteDirectory(Path: Text)
+ begin
+ CheckPath(Path);
+ CheckInitialization();
+ FileSystemConnector.DeleteDirectory(CurrFileAccount."Account Id", Path);
+ end;
+
+ procedure PathSeparator(): Text
+ begin
+ exit('/');
+ end;
+
+ procedure CombinePath(Path: Text; ChildPath: Text): Text
+ begin
+ if Path = '' then
+ exit(ChildPath);
+
+ if not Path.EndsWith(PathSeparator()) then
+ Path += PathSeparator();
+
+ exit(Path + ChildPath);
+ end;
+
+ procedure GetParentPath(Path: Text) ParentPath: Text
+ begin
+ Path := Path.TrimEnd(PathSeparator());
+ if Path.TrimEnd(PathSeparator()).Contains(PathSeparator()) then
+ ParentPath := Path.Substring(1, Path.LastIndexOf(PathSeparator()));
+ end;
+
+ procedure SelectFolderUI(Path: Text; DialogTitle: Text): Text
+ var
+ FileAccountContent: Record "File Account Content";
+ FileAccountBrowser: Page "File Account Browser";
+ begin
+ CheckPath(Path);
+ CheckInitialization();
+
+ FileAccountBrowser.SetPageCaption(DialogTitle);
+ FileAccountBrowser.SetFileAccount(CurrFileAccount);
+ FileAccountBrowser.EnableDirectoryLookupMode(Path);
+ if FileAccountBrowser.RunModal() <> Action::LookupOK then
+ exit('');
+
+ FileAccountBrowser.GetRecord(FileAccountContent);
+ if FileAccountContent.Type <> FileAccountContent.Type::Directory then
+ exit('');
+
+ exit(CombinePath(FileAccountContent."Parent Directory", FileAccountContent.Name));
+ end;
+
+ procedure SelectFileUI(Path: Text; FileFilter: Text; DialogTitle: Text): Text
+ var
+ FileAccountContent: Record "File Account Content";
+ FileAccountBrowser: Page "File Account Browser";
+ begin
+ CheckPath(Path);
+ CheckInitialization();
+
+ FileAccountBrowser.SetPageCaption(DialogTitle);
+ FileAccountBrowser.SetFileAccount(CurrFileAccount);
+ FileAccountBrowser.EnableFileLookupMode(Path, FileFilter);
+ if FileAccountBrowser.RunModal() <> Action::LookupOK then
+ exit('');
+
+ FileAccountBrowser.GetRecord(FileAccountContent);
+ if FileAccountContent.Type <> FileAccountContent.Type::File then
+ exit('');
+
+ exit(CombinePath(FileAccountContent."Parent Directory", FileAccountContent.Name));
+ end;
+
+ procedure SaveFileUI(Path: Text; FileExtension: Text; DialogTitle: Text): Text
+ var
+ FileAccountBrowser: Page "File Account Browser";
+ FileName, FileNameWithExtension : Text;
+ PleaseProvideFileExtensionErr: Label 'Please provide a valid file extension.';
+ FileNameTok: Label '%1.%2', Locked = true;
+ begin
+ CheckPath(Path);
+ CheckInitialization();
+
+ if FileExtension = '' then
+ Error(PleaseProvideFileExtensionErr);
+
+ FileAccountBrowser.SetPageCaption(DialogTitle);
+ FileAccountBrowser.SetFileAccount(CurrFileAccount);
+ FileAccountBrowser.EnableSaveFileLookupMode(Path, FileExtension);
+ if FileAccountBrowser.RunModal() <> Action::LookupOK then
+ exit('');
+
+ FileName := FileAccountBrowser.GetFileName();
+ if FileName = '' then
+ exit('');
+
+ FileNameWithExtension := StrSubstNo(FileNameTok, FileName, FileExtension);
+ exit(CombinePath(FileAccountBrowser.GetCurrentDirectory(), FileNameWithExtension));
+ end;
+
+ procedure BrowseAccount()
+ var
+ FileAccountImpl: Codeunit "File Account Impl.";
+ begin
+ CheckInitialization();
+ FileAccountImpl.BrowseAccount(CurrFileAccount);
+ end;
+
+ local procedure CheckInitialization()
+ var
+ NotInitializedErr: Label 'Please call Initialize() first.';
+ begin
+ if IsInitialized then
+ exit;
+
+ Error(NotInitializedErr);
+ end;
+
+ local procedure CheckPath(Path: Text)
+ var
+ InvalidChar: Char;
+ PathCannotStartWithSlashErr: Label 'The path %1 can not start with /.', Comment = '%1 - Path';
+ InvalidChars: Text;
+
+ begin
+ if Path.StartsWith('/') then
+ Error(PathCannotStartWithSlashErr, Path);
+
+ InvalidChars := '"''<>\|';
+ foreach InvalidChar in InvalidChars do
+ CheckPath(Path, InvalidChar);
+ end;
+
+ local procedure CheckPath(Path: Text; InvalidChar: Char)
+ var
+ InvalidPathErr: Label 'The path %1 contains the invalid character %2.', Comment = '%1 - Path, %2 - Invalid Character';
+ begin
+ if Path.Contains(InvalidChar) then
+ Error(InvalidPathErr, Path, InvalidChar);
+ end;
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Lookup/FileAccountBrowser.Page.al b/src/System Application/App/File System/src/Lookup/FileAccountBrowser.Page.al
new file mode 100644
index 0000000000..b247200e1d
--- /dev/null
+++ b/src/System Application/App/File System/src/Lookup/FileAccountBrowser.Page.al
@@ -0,0 +1,208 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+page 9455 "File Account Browser"
+{
+ Caption = 'File Account Browser';
+ PageType = List;
+ ApplicationArea = All;
+ SourceTable = "File Account Content";
+ ModifyAllowed = false;
+ InsertAllowed = false;
+ DeleteAllowed = false;
+ Extensible = false;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+ UsageCategory = None;
+
+ layout
+ {
+ area(Content)
+ {
+ field(CurrentPathField; CurrentPath)
+ {
+ Caption = 'Path';
+ ShowCaption = false;
+ Editable = false;
+ }
+ repeater(General)
+ {
+ field(Name; Rec.Name)
+ {
+ DrillDown = true;
+ ToolTip = 'Specifies the value of the Name field.';
+
+ trigger OnDrillDown()
+ begin
+ case true of
+ (Rec.Name = '..'):
+ BrowseFolder(Rec."Parent Directory");
+ (Rec.Type = Rec.Type::Directory):
+ BrowseFolder(Rec);
+ (not IsInLookupMode):
+ FileAccountBrowserMgt.DownloadFile(Rec);
+ end;
+ end;
+ }
+ field("Type"; Rec."Type")
+ {
+ ToolTip = 'Specifies the value of the Type field.';
+ }
+ }
+
+ group(SaveFileNameGroup)
+ {
+ Caption = '', Locked = true;
+ ShowCaption = false;
+ Visible = ShowFileName;
+
+ field(SaveFileNameField; SaveFileName)
+ {
+ Caption = 'Filename';
+ ToolTip = 'Specifies the Name of the File.';
+ }
+ }
+ }
+ }
+
+ actions
+ {
+ area(Promoted)
+ {
+ actionref(UploadRef; Upload) { }
+ actionref(CreateDirectoryRef; "Create Directory") { }
+ actionref(DeleteRef; Delete) { }
+ }
+ area(Processing)
+ {
+ action(Upload)
+ {
+ Caption = 'Upload';
+ Image = Import;
+ Ellipsis = true;
+ Visible = not IsInLookupMode;
+ Enabled = not IsInLookupMode;
+ ToolTip = 'Uploads a file to the current directory.';
+
+ trigger OnAction()
+ begin
+ FileAccountBrowserMgt.UploadFile(CurrentPath);
+ BrowseFolder(CurrentPath);
+ end;
+ }
+ action("Create Directory")
+ {
+ Caption = 'Create Directory';
+ Image = Bin;
+ Ellipsis = true;
+ Visible = not IsInLookupMode;
+ Enabled = not IsInLookupMode;
+ ToolTip = 'Creates a new directory in the current directory.';
+
+ trigger OnAction()
+ begin
+ FileAccountBrowserMgt.CreateDirectory(CurrentPath);
+ BrowseFolder(CurrentPath);
+ end;
+ }
+ action(Delete)
+ {
+ Caption = 'Delete';
+ Image = Delete;
+ Ellipsis = true;
+ Visible = not IsInLookupMode;
+ Enabled = not IsInLookupMode;
+ ToolTip = 'Deletes the selected file or directory.';
+
+ trigger OnAction()
+ begin
+ FileAccountBrowserMgt.DeleteFileOrDirectory(Rec);
+ BrowseFolder(CurrentPath);
+ end;
+ }
+ }
+ }
+
+ var
+ FileAccountBrowserMgt: Codeunit "File Account Browser Mgt.";
+ CurrentPath, FileFilter, SaveFileName, CurrentPageCaption : Text;
+ DoNotLoadFiles, IsInLookupMode, ShowFileName : Boolean;
+
+ trigger OnOpenPage()
+ begin
+ if CurrentPageCaption <> '' then
+ CurrPage.Caption(CurrentPageCaption);
+ end;
+
+ internal procedure SetFileAccount(FileAccount: Record "File Account")
+ begin
+ FileAccountBrowserMgt.SetFileAccount(FileAccount);
+ end;
+
+ internal procedure BrowseFileAccount(Path: Text)
+ begin
+ BrowseFolder('');
+ end;
+
+ internal procedure EnableFileLookupMode(Path: Text; PassedFileFilter: Text)
+ begin
+ FileFilter := PassedFileFilter;
+ EnableLookupMode();
+ BrowseFolder(Path);
+ end;
+
+ internal procedure EnableDirectoryLookupMode(Path: Text)
+ begin
+ DoNotLoadFiles := true;
+ EnableLookupMode();
+ BrowseFolder(Path);
+ end;
+
+ internal procedure EnableSaveFileLookupMode(Path: Text; FileExtension: Text)
+ var
+ FileFilterTok: Label '*.%1', Locked = true;
+ begin
+ ShowFileName := true;
+ FileFilter := StrSubstNo(FileFilterTok, FileExtension);
+ EnableLookupMode();
+ BrowseFolder(Path);
+ end;
+
+ internal procedure GetCurrentDirectory(): Text
+ begin
+ exit(CurrentPath);
+ end;
+
+ internal procedure GetFileName(): Text
+ begin
+ exit(SaveFileName);
+ end;
+
+ internal procedure SetPageCaption(NewCaption: Text)
+ begin
+ CurrentPageCaption := NewCaption;
+ end;
+
+ local procedure EnableLookupMode()
+ begin
+ IsInLookupMode := true;
+ CurrPage.LookupMode(true);
+ end;
+
+ local procedure BrowseFolder(var TempFileAccountContent: Record "File Account Content" temporary)
+ var
+ Path: Text;
+ begin
+ Path := FileAccountBrowserMgt.CombinePath(TempFileAccountContent."Parent Directory", TempFileAccountContent.Name);
+ BrowseFolder(Path);
+ end;
+
+ local procedure BrowseFolder(Path: Text)
+ begin
+ FileAccountBrowserMgt.BrowseFolder(Rec, Path, CurrentPath, DoNotLoadFiles, FileFilter);
+ end;
+}
diff --git a/src/System Application/App/File System/src/Lookup/FileAccountBrowserMgt.Codeunit.al b/src/System Application/App/File System/src/Lookup/FileAccountBrowserMgt.Codeunit.al
new file mode 100644
index 0000000000..abcfe1247d
--- /dev/null
+++ b/src/System Application/App/File System/src/Lookup/FileAccountBrowserMgt.Codeunit.al
@@ -0,0 +1,134 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+codeunit 9458 "File Account Browser Mgt."
+{
+ Access = Internal;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+
+ var
+ FileSystem: Codeunit "File System";
+
+ procedure SetFileAccount(FileAccount: Record "File Account")
+ begin
+ FileSystem.Initialize(FileAccount);
+ end;
+
+ procedure StripNotSupportedCharsInFileName(InText: Text): Text
+ var
+ InvalidCharsStringTxt: Label '"#%&*:<>?\/{|}~', Locked = true;
+ begin
+ InText := DelChr(InText, '=', InvalidCharsStringTxt);
+ exit(InText);
+ end;
+
+ procedure BrowseFolder(var TempFileAccountContent: Record "File Account Content" temporary; Path: Text; var CurrentPath: Text; DoNotLoadFiles: Boolean; FileNameFilter: Text)
+ var
+ FilePaginationData: Codeunit "File Pagination Data";
+ begin
+ CurrentPath := Path.TrimEnd('/');
+ TempFileAccountContent.DeleteAll();
+
+ repeat
+ FileSystem.ListDirectories(Path, FilePaginationData, TempFileAccountContent);
+ until FilePaginationData.IsEndOfListing();
+
+ ListFiles(TempFileAccountContent, Path, DoNotLoadFiles, CurrentPath, FileNameFilter);
+ if TempFileAccountContent.FindFirst() then;
+ end;
+
+ procedure DownloadFile(var TempFileAccountContent: Record "File Account Content" temporary)
+ var
+ Stream: InStream;
+ FileName: Text;
+ begin
+ FileSystem.GetFile(FileSystem.CombinePath(TempFileAccountContent."Parent Directory", TempFileAccountContent.Name), Stream);
+ FileName := TempFileAccountContent.Name;
+ DownloadFromStream(Stream, '', '', '', FileName);
+ end;
+
+ procedure UploadFile(Path: Text)
+ var
+ Stream: InStream;
+ UploadDialogTxt: Label 'Upload File';
+ FromFile: Text;
+ begin
+ if not UploadIntoStream(UploadDialogTxt, '', '', FromFile, Stream) then
+ exit;
+
+ FileSystem.CreateFile(FileSystem.CombinePath(Path, FromFile), Stream);
+ end;
+
+ procedure CreateDirectory(Path: Text)
+ var
+ FolderNameInput: Page "Folder Name Input";
+ FolderName: Text;
+ begin
+ if FolderNameInput.RunModal() <> Action::OK then
+ exit;
+
+ FolderName := StripNotSupportedCharsInFileName(FolderNameInput.GetFolderName());
+ FileSystem.CreateDirectory(FileSystem.CombinePath(Path, FolderName));
+ end;
+
+ local procedure ListFiles(var FileAccountContent: Record "File Account Content" temporary; Path: Text; DoNotLoadFields: Boolean; CurrentPath: Text; FileNameFilter: Text)
+ var
+ TempFileAccountContentToAdd: Record "File Account Content" temporary;
+ FilePaginationData: Codeunit "File Pagination Data";
+ begin
+ if DoNotLoadFields then
+ exit;
+
+ repeat
+ FileSystem.ListFiles(Path, FilePaginationData, FileAccountContent);
+ until FilePaginationData.IsEndOfListing();
+
+ AddFiles(FileAccountContent, TempFileAccountContentToAdd, CurrentPath, FileNameFilter);
+ end;
+
+ local procedure AddFiles(var FileAccountContent: Record "File Account Content" temporary; var FileAccountContentToAdd: Record "File Account Content" temporary; CurrentPath: Text; FileNameFilter: Text)
+ begin
+ if FileNameFilter <> '' then
+ FileAccountContentToAdd.SetFilter(Name, FileNameFilter);
+
+ if FileAccountContentToAdd.FindSet() then
+ repeat
+ FileAccountContent.Init();
+ FileAccountContent.TransferFields(FileAccountContentToAdd);
+ FileAccountContent.Insert();
+ until FileAccountContentToAdd.Next() = 0;
+
+ FileAccountContent.Init();
+ FileAccountContent.Name := '..';
+ FileAccountContent.Type := FileAccountContent.Type::Directory;
+ FileAccountContent."Parent Directory" := CopyStr(FileSystem.GetParentPath(CurrentPath), 1, MaxStrLen(FileAccountContent."Parent Directory"));
+ FileAccountContent.Insert();
+ end;
+
+ procedure DeleteFileOrDirectory(var TempFileAccountContent: Record "File Account Content" temporary)
+ var
+ DeleteQst: Label 'Delete %1?', Comment = '%1 - Path to Delete';
+ PathToDelete: Text;
+ begin
+ PathToDelete := FileSystem.CombinePath(TempFileAccountContent."Parent Directory", TempFileAccountContent.Name);
+ if not Confirm(DeleteQst, false, PathToDelete) then
+ exit;
+
+ case TempFileAccountContent.Type of
+ TempFileAccountContent.Type::Directory:
+ FileSystem.DeleteDirectory(PathToDelete);
+ TempFileAccountContent.Type::File:
+ FileSystem.DeleteFile(PathToDelete);
+ end;
+ end;
+
+ internal procedure CombinePath(Path: Text; ChildPath: Text): Text
+ begin
+ exit(FileSystem.CombinePath(Path, ChildPath));
+ end;
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Lookup/FileAccountContent.Table.al b/src/System Application/App/File System/src/Lookup/FileAccountContent.Table.al
new file mode 100644
index 0000000000..3dab1f86c2
--- /dev/null
+++ b/src/System Application/App/File System/src/Lookup/FileAccountContent.Table.al
@@ -0,0 +1,39 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+table 9455 "File Account Content"
+{
+ Caption = 'File Account Content';
+ DataClassification = SystemMetadata;
+ TableType = Temporary;
+
+ fields
+ {
+ field(1; "Type"; Enum "File Type")
+ {
+ Caption = 'Type';
+ DataClassification = ToBeClassified;
+ }
+ field(2; Name; Text[2048])
+ {
+ Caption = 'Name';
+ DataClassification = ToBeClassified;
+ }
+ field(10; "Parent Directory"; Text[2048])
+ {
+ Caption = 'Parent Directory';
+ DataClassification = ToBeClassified;
+ }
+ }
+ keys
+ {
+ key(PK; "Type", Name)
+ {
+ Clustered = true;
+ }
+ }
+}
diff --git a/src/System Application/App/File System/src/Lookup/FilePaginationData.Codeunit.al b/src/System Application/App/File System/src/Lookup/FilePaginationData.Codeunit.al
new file mode 100644
index 0000000000..87cdfb4a06
--- /dev/null
+++ b/src/System Application/App/File System/src/Lookup/FilePaginationData.Codeunit.al
@@ -0,0 +1,51 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+codeunit 9456 "File Pagination Data"
+{
+ InherentPermissions = X;
+ InherentEntitlements = X;
+
+ var
+ FilePaginationDataImpl: Codeunit "File Pagination Data Impl.";
+
+ ///
+ /// Sets a marker to see if files and directories can be retrieved in batches.
+ ///
+ /// Marker value to set.
+ procedure SetMarker(NewMarker: Text)
+ begin
+ FilePaginationDataImpl.SetMarker(NewMarker);
+ end;
+
+ ///
+ /// Gets the current marker value.
+ ///
+ /// Current marker value.
+ procedure GetMarker(): Text
+ begin
+ exit(FilePaginationDataImpl.GetMarker());
+ end;
+
+ ///
+ /// Set this value to true, if all files or directories have been read a from the File System.
+ ///
+ /// End of listing reached.
+ procedure SetEndOfListing(NewEndOfListing: Boolean)
+ begin
+ FilePaginationDataImpl.SetEndOfListing(NewEndOfListing);
+ end;
+
+ ///
+ /// Defines if all batches of directory or file listing has been received.
+ ///
+ /// End of listing reached.
+ procedure IsEndOfListing(): Boolean
+ begin
+ exit(FilePaginationDataImpl.IsEndOfListing());
+ end;
+}
diff --git a/src/System Application/App/File System/src/Lookup/FilePaginationDataImpl.Codeunit.al b/src/System Application/App/File System/src/Lookup/FilePaginationDataImpl.Codeunit.al
new file mode 100644
index 0000000000..bd5738d983
--- /dev/null
+++ b/src/System Application/App/File System/src/Lookup/FilePaginationDataImpl.Codeunit.al
@@ -0,0 +1,37 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+codeunit 9457 "File Pagination Data Impl."
+{
+ Access = Internal;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+
+ var
+ EndOfListing: Boolean;
+ Marker: Text;
+
+ procedure SetMarker(NewMarker: Text)
+ begin
+ Marker := NewMarker;
+ end;
+
+ procedure GetMarker(): Text
+ begin
+ exit(Marker);
+ end;
+
+ procedure SetEndOfListing(NewEndOfListing: Boolean)
+ begin
+ EndOfListing := NewEndOfListing;
+ end;
+
+ procedure IsEndOfListing(): Boolean
+ begin
+ exit(EndOfListing);
+ end;
+}
diff --git a/src/System Application/App/File System/src/Lookup/FileType.Enum.al b/src/System Application/App/File System/src/Lookup/FileType.Enum.al
new file mode 100644
index 0000000000..4fa30d0589
--- /dev/null
+++ b/src/System Application/App/File System/src/Lookup/FileType.Enum.al
@@ -0,0 +1,31 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+///
+/// Indicator of what type the resource is.
+///
+enum 9452 "File Type"
+{
+ Access = Public;
+ Extensible = false;
+
+ ///
+ /// Indicates if entry is a directory.
+ ///
+ value(0; Directory)
+ {
+ Caption = 'Directory';
+ }
+
+ ///
+ /// Indicates if entry is a file type.
+ ///
+ value(1; File)
+ {
+ Caption = 'File';
+ }
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Lookup/FolderNameInput.Page.al b/src/System Application/App/File System/src/Lookup/FolderNameInput.Page.al
new file mode 100644
index 0000000000..8631f97b75
--- /dev/null
+++ b/src/System Application/App/File System/src/Lookup/FolderNameInput.Page.al
@@ -0,0 +1,36 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+page 9456 "Folder Name Input"
+{
+ ApplicationArea = All;
+ Caption = 'Create Folder...';
+ PageType = StandardDialog;
+ Extensible = false;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+
+ layout
+ {
+ area(Content)
+ {
+ field(FolderNameField; FolderName)
+ {
+ Caption = 'Folder Name';
+ ToolTip = 'Specifies the Name of the directory.';
+ }
+ }
+ }
+
+ var
+ FolderName: Text;
+
+ internal procedure GetFolderName(): Text
+ begin
+ exit(FolderName);
+ end;
+}
diff --git a/src/System Application/App/File System/src/Scenario/FileAccountScenario.Table.al b/src/System Application/App/File System/src/Scenario/FileAccountScenario.Table.al
new file mode 100644
index 0000000000..209cd7ef9b
--- /dev/null
+++ b/src/System Application/App/File System/src/Scenario/FileAccountScenario.Table.al
@@ -0,0 +1,65 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+///
+/// Temporary table used to display the tree structure in "File Scenario Setup".
+///
+table 9453 "File Account Scenario"
+{
+ Access = Internal;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+ TableType = Temporary;
+
+ fields
+ {
+ field(1; Scenario; Integer)
+ {
+ DataClassification = SystemMetadata;
+ }
+ field(2; Connector; Enum "File System Connector")
+ {
+ DataClassification = SystemMetadata;
+ }
+ field(3; "Account Id"; Guid)
+ {
+ DataClassification = SystemMetadata;
+ }
+ field(4; "Display Name"; Text[2048])
+ {
+ DataClassification = SystemMetadata;
+ }
+ field(5; Default; Boolean)
+ {
+ DataClassification = SystemMetadata;
+ }
+ field(6; EntryType; Option)
+ {
+ DataClassification = SystemMetadata;
+ OptionMembers = Account,Scenario;
+ }
+ field(7; Position; Integer)
+ {
+ DataClassification = SystemMetadata;
+ }
+ }
+
+ keys
+ {
+ key(PK; Scenario, "Account Id", Connector)
+ {
+ Clustered = true;
+ }
+ key(Position; Position)
+ {
+ }
+ key(Name; "Display Name")
+ {
+ Description = 'Used for sorting by Display Name';
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Scenario/FileScenario.Codeunit.al b/src/System Application/App/File System/src/Scenario/FileScenario.Codeunit.al
new file mode 100644
index 0000000000..6bc25d5574
--- /dev/null
+++ b/src/System Application/App/File System/src/Scenario/FileScenario.Codeunit.al
@@ -0,0 +1,79 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+///
+/// Provides functionality to work with file scenarios.
+///
+codeunit 9452 "File Scenario"
+{
+ InherentPermissions = X;
+ InherentEntitlements = X;
+
+ ///
+ /// Gets the default file account.
+ ///
+ /// Out parameter holding information about the default file account.
+ /// True if an account for the default scenario was found; otherwise - false.
+ procedure GetDefaultFileAccount(var FileAccount: Record "File Account"): Boolean
+ begin
+ exit(FileScenarioImpl.GetFileAccount(Enum::"File Scenario"::Default, FileAccount));
+ end;
+
+ ///
+ /// Gets the file account used by the given file scenario.
+ /// If the no account is defined for the provided scenario, the default account (if defined) will be returned.
+ ///
+ /// The scenario to look for.
+ /// Out parameter holding information about the file account.
+ /// True if an account for the specified scenario was found; otherwise - false.
+ procedure GetFileAccount(Scenario: Enum "File Scenario"; var FileAccount: Record "File Account"): Boolean
+ begin
+ exit(FileScenarioImpl.GetFileAccount(Scenario, FileAccount));
+ end;
+
+ ///
+ /// Sets a default file account.
+ ///
+ /// The file account to use.
+ procedure SetDefaultFileAccount(FileAccount: Record "File Account")
+ begin
+ FileScenarioImpl.SetFileAccount(Enum::"File Scenario"::Default, FileAccount);
+ end;
+
+ ///
+ /// Sets a file account to be used by the given file scenario.
+ ///
+ /// The scenario for which to set a file account.
+ /// The file account to use.
+ procedure SetFileAccount(Scenario: Enum "File Scenario"; FileAccount: Record "File Account")
+ begin
+ FileScenarioImpl.SetFileAccount(Scenario, FileAccount);
+ end;
+
+ ///
+ /// Unassign an file scenario. The scenario will then use the default file account.
+ ///
+ /// The scenario to unassign.
+ procedure UnassignScenario(Scenario: Enum "File Scenario")
+ begin
+ FileScenarioImpl.UnassignScenario(Scenario);
+ end;
+
+ ///
+ /// Event for changing whether an file scenario should be added to the list of assignable scenarios.
+ /// If the scenario has already been assigned or is the default scenario, this event won't be published.
+ ///
+ /// The scenario that is going to be added to the list of assignable scenarios.
+ /// The return for whether this scenario should be listed in the assignable scenarios list.
+ [IntegrationEvent(false, false, true)]
+ internal procedure OnBeforeInsertAvailableFileScenario(Scenario: Enum "File Scenario"; var IsAvailable: Boolean)
+ begin
+ end;
+
+ var
+ FileScenarioImpl: Codeunit "File Scenario Impl.";
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Scenario/FileScenario.Enum.al b/src/System Application/App/File System/src/Scenario/FileScenario.Enum.al
new file mode 100644
index 0000000000..7a98b32770
--- /dev/null
+++ b/src/System Application/App/File System/src/Scenario/FileScenario.Enum.al
@@ -0,0 +1,24 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+///
+/// File scenarios.
+/// Used to decouple file accounts from sending files.
+///
+enum 9451 "File Scenario"
+{
+ Extensible = true;
+
+ ///
+ /// The default file scenario.
+ /// Used in the cases where no other scenario is defined.
+ ///
+ value(0; Default)
+ {
+ Caption = 'Default';
+ }
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Scenario/FileScenario.Table.al b/src/System Application/App/File System/src/Scenario/FileScenario.Table.al
new file mode 100644
index 0000000000..caa1f0ae42
--- /dev/null
+++ b/src/System Application/App/File System/src/Scenario/FileScenario.Table.al
@@ -0,0 +1,42 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+///
+/// Holds the mapping between file account and scenarios.
+/// One scenarios is mapped to one file account.
+/// One file account can be used for multiple scenarios.
+///
+table 9454 "File Scenario"
+{
+ Access = Internal;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+
+ fields
+ {
+ field(1; Scenario; Enum "File Scenario")
+ {
+ DataClassification = SystemMetadata;
+ }
+ field(2; Connector; Enum "File System Connector")
+ {
+ DataClassification = SystemMetadata;
+ }
+ field(3; "Account Id"; Guid)
+ {
+ DataClassification = SystemMetadata;
+ }
+ }
+
+ keys
+ {
+ key(PK; Scenario)
+ {
+ Clustered = true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Scenario/FileScenarioImpl.Codeunit.al b/src/System Application/App/File System/src/Scenario/FileScenarioImpl.Codeunit.al
new file mode 100644
index 0000000000..99206aa62b
--- /dev/null
+++ b/src/System Application/App/File System/src/Scenario/FileScenarioImpl.Codeunit.al
@@ -0,0 +1,328 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+using System;
+
+codeunit 9453 "File Scenario Impl."
+{
+ Access = Internal;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+ Permissions = tabledata "File Scenario" = rimd;
+
+ procedure GetFileAccount(Scenario: Enum "File Scenario"; var FileAccount: Record "File Account"): Boolean
+ var
+ AllFileAccounts: Record "File Account";
+ FileScenario: Record "File Scenario";
+ FileAccounts: Codeunit "File Account";
+ begin
+ FileAccounts.GetAllAccounts(AllFileAccounts);
+
+ // Find the account for the provided scenario
+ if FileScenario.Get(Scenario) then
+ if AllFileAccounts.Get(FileScenario."Account Id", FileScenario.Connector) then begin
+ FileAccount := AllFileAccounts;
+ exit(true);
+ end;
+
+ // Fallback to the default account if the scenario isn't mapped or the mapped account doesn't exist
+ if FileScenario.Get(Enum::"File Scenario"::Default) then
+ if AllFileAccounts.Get(FileScenario."Account Id", FileScenario.Connector) then begin
+ FileAccount := AllFileAccounts;
+ exit(true);
+ end;
+
+ exit(false);
+ end;
+
+ procedure SetFileAccount(Scenario: Enum "File Scenario"; FileAccount: Record "File Account")
+ var
+ FileScenario: Record "File Scenario";
+ begin
+ if not FileScenario.Get(Scenario) then begin
+ FileScenario.Scenario := Scenario;
+ FileScenario.Insert();
+ end;
+
+ FileScenario."Account Id" := FileAccount."Account Id";
+ FileScenario.Connector := FileAccount.Connector;
+
+ FileScenario.Modify();
+ end;
+
+ procedure UnassignScenario(Scenario: Enum "File Scenario")
+ var
+ FileScenario: Record "File Scenario";
+ begin
+ if FileScenario.Get(Scenario) then
+ FileScenario.Delete();
+ end;
+
+ ///
+ /// Get a list of entries, representing a tree structure with file accounts and the scenarios, assigned to each account.
+ ///
+ ///
+ /// Account sales@cronus.com has scenarios "Sales Quote" and "Sales Credit Memo" assigned.
+ /// Account purchase@cronus.com has scenarios "Purchase Quote" and "Purchase Invoice" assigned.
+ /// The result of calling the function will be:
+ /// sales@cronus.com, "Sales Quote", "Sales Credit Memo", purchase@cronus.com, "Purchase Quote", "Purchase Invoice"
+ ///
+ /// A flattened tree structure representing all the file accounts and the scenarios assigned to them.
+ procedure GetScenariosByFileAccount(var FileAccountScenario: Record "File Account Scenario")
+ var
+ DefaultFileAccount: Record "File Account";
+ FileAccounts: Record "File Account";
+ FileAccountScenarios: Record "File Account Scenario";
+ FileAccount: Codeunit "File Account";
+ Default: Boolean;
+ Position: Integer;
+ DisplayName: Text[2048];
+ begin
+ FileAccountScenario.Reset();
+ FileAccountScenario.DeleteAll();
+
+ FileAccount.GetAllAccounts(FileAccounts);
+
+ if not FileAccounts.FindSet() then
+ exit; // No accounts, nothing to do
+
+ // The position is set in order to be able to properly sort the entries (by order of insertion)
+ Position := 1;
+ GetDefaultAccount(DefaultFileAccount);
+
+ repeat
+ Default := (FileAccounts."Account Id" = DefaultFileAccount."Account Id") and (FileAccounts.Connector = DefaultFileAccount.Connector);
+ DisplayName := FileAccounts.Name;
+
+ // Add entry for the file account. Scenario is -1, because it isn't needed when displaying the file account.
+ AddEntry(FileAccountScenario, FileAccountScenario.EntryType::Account, -1, FileAccounts."Account Id", FileAccounts.Connector, DisplayName, Default, Position);
+
+ // Get the file scenarios assigned to the current file account, sorted by "Display Name"
+ GetFileScenariosForAccount(FileAccounts, FileAccountScenarios);
+
+ if FileAccountScenarios.FindSet() then
+ repeat
+ // Add entry for every scenario that is assigned to the current file account
+ AddEntry(FileAccountScenario, FileAccountScenarios.EntryType::Scenario, FileAccountScenarios.Scenario, FileAccountScenarios."Account Id", FileAccountScenarios.Connector, FileAccountScenarios."Display Name", false, Position);
+ until FileAccountScenarios.Next() = 0;
+ until FileAccounts.Next() = 0;
+
+ // Order by position to show accurate results
+ FileAccountScenario.SetCurrentKey(Position);
+ end;
+
+ local procedure GetFileScenariosForAccount(FileAccount: Record "File Account"; var FileAccountScenarios: Record "File Account Scenario")
+ var
+ FileScenarios: Record "File Scenario";
+ ValidFileScenarios: DotNet Hashtable;
+ IsScenarioValid: Boolean;
+ Scenario: Integer;
+ begin
+ FileAccountScenarios.Reset();
+ FileAccountScenarios.DeleteAll();
+
+ // Get all file scenarios assigned to the file account
+ FileScenarios.SetRange("Account Id", FileAccount."Account Id");
+ FileScenarios.SetRange(Connector, FileAccount.Connector);
+
+ if not FileScenarios.FindSet() then
+ exit;
+
+ // Find all valid scenarios. Invalid scenario may occur if the extension that added them was removed.
+ ValidFileScenarios := ValidFileScenarios.Hashtable();
+ foreach Scenario in Enum::"File Scenario".Ordinals() do
+ ValidFileScenarios.Add(Scenario, Scenario);
+
+ // Convert File Scenario-s to File Account Scenario-s so they can be sorted by "Display Name"
+ repeat
+ IsScenarioValid := ValidFileScenarios.Contains(FileScenarios.Scenario.AsInteger());
+
+ // Add entry for every scenario that exists and uses the file account. Skip the default scenario.
+ if (FileScenarios.Scenario <> Enum::"File Scenario"::Default) and IsScenarioValid then begin
+ FileAccountScenarios.Scenario := FileScenarios.Scenario.AsInteger();
+ FileAccountScenarios."Account Id" := FileScenarios."Account Id";
+ FileAccountScenarios.Connector := FileScenarios.Connector;
+ FileAccountScenarios."Display Name" := Format(FileScenarios.Scenario);
+
+ FileAccountScenarios.Insert();
+ end;
+ until FileScenarios.Next() = 0;
+
+ FileAccountScenarios.SetCurrentKey("Display Name"); // sort scenarios by "Display Name"
+ end;
+
+ local procedure AddEntry(var FileAccountScenario: Record "File Account Scenario"; EntryType: Option; Scenario: Integer; AccountId: Guid; FileSystemConnector: Enum "File System Connector"; DisplayName: Text[2048]; Default: Boolean; var Position: Integer)
+ begin
+ // Add entry to the File Account Scenario while maintaining the position so that the tree represents the data correctly
+ FileAccountScenario.Init();
+ FileAccountScenario.EntryType := EntryType;
+ FileAccountScenario.Scenario := Scenario;
+ FileAccountScenario."Account Id" := AccountId;
+ FileAccountScenario.Connector := FileSystemConnector;
+ FileAccountScenario."Display Name" := DisplayName;
+ FileAccountScenario.Default := Default;
+ FileAccountScenario.Position := Position;
+ FileAccountScenario.Insert();
+
+ Position := Position + 1;
+ end;
+
+ procedure AddScenarios(FileAccountScenario: Record "File Account Scenario"): Boolean
+ var
+ SelectedFileAccScenarios: Record "File Account Scenario";
+ FileScenario: Record "File Scenario";
+ FileScenariosForAccount: Page "File Scenarios for Account";
+ begin
+ FileAccountImpl.CheckPermissions();
+
+ if FileAccountScenario.EntryType <> FileAccountScenario.EntryType::Account then // wrong entry, the entry should be of type "Account"
+ exit;
+
+ FileScenariosForAccount.Caption := StrSubstNo(ScenariosForAccountCaptionTxt, FileAccountScenario."Display Name");
+ FileScenariosForAccount.LookupMode(true);
+ FileScenariosForAccount.SetRecord(FileAccountScenario);
+
+ if FileScenariosForAccount.RunModal() <> Action::LookupOK then
+ exit(false);
+
+ FileScenariosForAccount.GetSelectedScenarios(SelectedFileAccScenarios);
+
+ if not SelectedFileAccScenarios.FindSet() then
+ exit(false);
+
+ repeat
+ if not FileScenario.Get(SelectedFileAccScenarios.Scenario) then begin
+ FileScenario."Account Id" := FileAccountScenario."Account Id";
+ FileScenario.Connector := FileAccountScenario.Connector;
+ FileScenario.Scenario := Enum::"File Scenario".FromInteger(SelectedFileAccScenarios.Scenario);
+
+ FileScenario.Insert();
+ end else begin
+ FileScenario."Account Id" := FileAccountScenario."Account Id";
+ FileScenario.Connector := FileAccountScenario.Connector;
+
+ FileScenario.Modify();
+ end;
+ until SelectedFileAccScenarios.Next() = 0;
+
+ exit(true);
+ end;
+
+ procedure GetAvailableScenariosForAccount(FileAccountScenario: Record "File Account Scenario"; var FileAccountScenarios: Record "File Account Scenario")
+ var
+ Scenario: Record "File Scenario";
+ FileScenario: Codeunit "File Scenario";
+ CurrentScenario, i : Integer;
+ IsAvailable: Boolean;
+ begin
+ FileAccountScenarios.Reset();
+ FileAccountScenarios.DeleteAll();
+ i := 1;
+
+ foreach CurrentScenario in Enum::"File Scenario".Ordinals() do begin
+ Clear(Scenario);
+ Scenario.SetRange("Account Id", FileAccountScenarios."Account Id");
+ Scenario.SetRange(Connector, FileAccountScenarios.Connector);
+ Scenario.SetRange(Scenario, CurrentScenario);
+
+ // If the scenario isn't already connected to the file account, then it's available. Natually, we skip the default scenario
+ IsAvailable := Scenario.IsEmpty() and (not (CurrentScenario = Enum::"File Scenario"::Default.AsInteger()));
+
+ // If the scenario is available, allow partner to determine if it should be shown
+ if IsAvailable then
+ FileScenario.OnBeforeInsertAvailableFileScenario(Enum::"File Scenario".FromInteger(CurrentScenario), IsAvailable);
+
+ if IsAvailable then begin
+ FileAccountScenarios."Account Id" := FileAccountScenarios."Account Id";
+ FileAccountScenarios.Connector := FileAccountScenarios.Connector;
+ FileAccountScenarios.Scenario := CurrentScenario;
+ FileAccountScenarios."Display Name" := Format(Enum::"File Scenario".FromInteger(Enum::"File Scenario".Ordinals().Get(i)));
+
+ FileAccountScenarios.Insert();
+ end;
+
+ i += 1;
+ end;
+ end;
+
+ procedure ChangeAccount(var FileAccountScenario: Record "File Account Scenario"): Boolean
+ var
+ SelectedFileAccount: Record "File Account";
+ FileScenario: Record "File Scenario";
+ FileAccount: Codeunit "File Account";
+ AccountsPage: Page "File Accounts";
+ begin
+ FileAccountImpl.CheckPermissions();
+
+ if not FileAccountScenario.FindSet() then
+ exit(false);
+
+ FileAccount.GetAllAccounts(false, SelectedFileAccount);
+ if SelectedFileAccount.Get(FileAccountScenario."Account Id", FileAccountScenario.Connector) then;
+
+ AccountsPage.EnableLookupMode();
+ AccountsPage.SetRecord(SelectedFileAccount);
+ AccountsPage.Caption := ChangeFileAccountForScenarioTxt;
+
+ if AccountsPage.RunModal() <> Action::LookupOK then
+ exit(false);
+
+ AccountsPage.GetAccount(SelectedFileAccount);
+
+ if IsNullGuid(SelectedFileAccount."Account Id") then // defensive check, no account was selected
+ exit;
+
+ repeat
+ if FileScenario.Get(FileAccountScenario.Scenario) then begin
+ FileScenario."Account Id" := SelectedFileAccount."Account Id";
+ FileScenario.Connector := SelectedFileAccount.Connector;
+
+ FileScenario.Modify();
+ end;
+ until FileAccountScenario.Next() = 0;
+
+ exit(true);
+ end;
+
+ procedure DeleteScenario(var FileAccountScenario: Record "File Account Scenario"): Boolean
+ var
+ FileScenario: Record "File Scenario";
+ begin
+ FileAccountImpl.CheckPermissions();
+
+ if not FileAccountScenario.FindSet() then
+ exit(false);
+
+ repeat
+ if FileAccountScenario.EntryType = FileAccountScenario.EntryType::Scenario then begin
+ FileScenario.SetRange(Scenario, FileAccountScenario.Scenario);
+ FileScenario.SetRange("Account Id", FileAccountScenario."Account Id");
+ FileScenario.SetRange(Connector, FileAccountScenario.Connector);
+
+ FileScenario.DeleteAll();
+ end;
+ until FileAccountScenario.Next() = 0;
+
+ exit(true);
+ end;
+
+ local procedure GetDefaultAccount(var FileAccount: Record "File Account")
+ var
+ FileScenario: Record "File Scenario";
+ begin
+ if not FileScenario.Get(Enum::"File Scenario"::Default) then
+ exit;
+
+ FileAccount."Account Id" := FileScenario."Account Id";
+ FileAccount.Connector := FileScenario.Connector;
+ end;
+
+ var
+ FileAccountImpl: Codeunit "File Account Impl.";
+ ChangeFileAccountForScenarioTxt: Label 'Change file account used for the selected scenarios';
+ ScenariosForAccountCaptionTxt: Label 'Assign scenarios to account %1', Comment = '%1 = the name of the e-file account';
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Scenario/FileScenarioSetup.Page.al b/src/System Application/App/File System/src/Scenario/FileScenarioSetup.Page.al
new file mode 100644
index 0000000000..da761208d2
--- /dev/null
+++ b/src/System Application/App/File System/src/Scenario/FileScenarioSetup.Page.al
@@ -0,0 +1,193 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+using System.Telemetry;
+
+///
+/// Page is used to display file scenarios usage by file accounts.
+///
+page 9452 "File Scenario Setup"
+{
+ Caption = 'File Scenario Assignment';
+ PageType = List;
+ UsageCategory = Administration;
+ ApplicationArea = All;
+ Extensible = false;
+ Editable = false;
+ DeleteAllowed = false;
+ InsertAllowed = false;
+ ModifyAllowed = false;
+ SourceTable = "File Account Scenario";
+ InstructionalText = 'Assign file scenarios';
+ InherentPermissions = X;
+ InherentEntitlements = X;
+
+ layout
+ {
+ area(Content)
+ {
+ repeater(ScenariosByFile)
+ {
+ IndentationColumn = Indentation;
+ IndentationControls = Name;
+ ShowAsTree = true;
+
+ field(Name; Rec."Display Name")
+ {
+ Caption = 'Scenarios by file accounts';
+ ToolTip = 'Specifies the scenarios that are using the file account.';
+ Editable = false;
+ StyleExpr = Style;
+ }
+ field(Default; DefaultTxt)
+ {
+ Caption = 'Default';
+ ToolTip = 'Specifies whether this is the default account to use for scenarios when no other account is specified.';
+ StyleExpr = Style;
+ }
+ }
+ }
+ }
+
+ actions
+ {
+ area(Processing)
+ {
+ group(Account)
+ {
+ action(AddScenario)
+ {
+ Visible = (TypeOfEntry = TypeOfEntry::Account) and CanUserManageFileSetup;
+ Caption = 'Assign scenarios';
+ ToolTip = 'Assign file scenarios for the selected file account. When assigned, everyone will use the account for the scenario. For example, if you assign the Sales Order scenario, everyone will use the account to send sales orders.';
+ Image = NewDocument;
+ Scope = Repeater;
+
+ trigger OnAction()
+ begin
+ SelectedFileAccountScenario := Rec;
+ FileScenarioImpl.AddScenarios(Rec);
+
+ FileScenarioImpl.GetScenariosByFileAccount(Rec);
+ SetSelectedRecord();
+ end;
+ }
+ }
+
+ group(Scenario)
+ {
+ action(ChangeAccount)
+ {
+ Visible = (TypeOfEntry = TypeOfEntry::Scenario) and CanUserManageFileSetup;
+ Caption = 'Reassign';
+ ToolTip = 'Reassign the selected scenarios to another file account.';
+ Image = Change;
+ Scope = Repeater;
+
+ trigger OnAction()
+ begin
+ CurrPage.SetSelectionFilter(Rec);
+ SelectedFileAccountScenario := Rec;
+
+ FileScenarioImpl.ChangeAccount(Rec);
+ FileScenarioImpl.GetScenariosByFileAccount(Rec); // refresh the data on the page
+ SetSelectedRecord();
+ end;
+ }
+ action(Unassign)
+ {
+ Visible = (TypeOfEntry = TypeOfEntry::Scenario) and CanUserManageFileSetup;
+ Caption = 'Unassign';
+ ToolTip = 'Unassign the selected scenarios. Afterward, the default file account will be used to send files for the scenarios.';
+ Image = Delete;
+ Scope = Repeater;
+
+ trigger OnAction()
+ begin
+ CurrPage.SetSelectionFilter(Rec);
+ SelectedFileAccountScenario := Rec;
+
+ FileScenarioImpl.DeleteScenario(Rec);
+ FileScenarioImpl.GetScenariosByFileAccount(Rec); // refresh the data on the page
+ SetSelectedRecord();
+ end;
+ }
+ }
+ }
+ area(Promoted)
+ {
+ group(Category_Process)
+ {
+ actionref(AddScenario_Promoted; AddScenario)
+ {
+ }
+ actionref(ChangeAccount_Promoted; ChangeAccount)
+ {
+ }
+ actionref(Unassign_Promoted; Unassign)
+ {
+ }
+ }
+ }
+ }
+
+ trigger OnOpenPage()
+ var
+ FeatureTelemetry: Codeunit "Feature Telemetry";
+ begin
+ FeatureTelemetry.LogUptake('0000CTN', 'File Access', Enum::"Feature Uptake Status"::Discovered);
+ CanUserManageFileSetup := FileAccountImpl.IsUserFileAdmin();
+ FileScenarioImpl.GetScenariosByFileAccount(Rec);
+
+ // Set selection
+ if not Rec.Get(-1, FileAccountId, FileConnector) then
+ if Rec.FindFirst() then;
+ end;
+
+ trigger OnAfterGetRecord()
+ begin
+ DefaultTxt := '';
+
+ TypeOfEntry := Rec.EntryType;
+
+ if TypeOfEntry = TypeOfEntry::Account then begin
+ Indentation := 0;
+ Style := 'Strong';
+ if Rec.Default then
+ DefaultTxt := '✓'
+ end;
+
+ if TypeOfEntry = TypeOfEntry::Scenario then begin
+ Indentation := 1;
+ Style := 'Standard';
+ end;
+ end;
+
+ // Used to set the focus on a file account
+ internal procedure SetFileAccountId(AccountId: Guid; Connector: Enum "File System Connector")
+ begin
+ FileAccountId := AccountId;
+ FileConnector := Connector;
+ end;
+
+ local procedure SetSelectedRecord()
+ begin
+ if not Rec.Get(SelectedFileAccountScenario.Scenario, SelectedFileAccountScenario."Account Id", SelectedFileAccountScenario.Connector) then
+ Rec.FindFirst();
+ end;
+
+ var
+ SelectedFileAccountScenario: Record "File Account Scenario";
+ FileScenarioImpl: Codeunit "File Scenario Impl.";
+ FileAccountImpl: Codeunit "File Account Impl.";
+ FileAccountId: Guid;
+ FileConnector: Enum "File System Connector";
+ Style, DefaultTxt : Text;
+ TypeOfEntry: Option Account,Scenario;
+ Indentation: Integer;
+ CanUserManageFileSetup: Boolean;
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Scenario/FileScenariosFactBox.Page.al b/src/System Application/App/File System/src/Scenario/FileScenariosFactBox.Page.al
new file mode 100644
index 0000000000..a01b690d42
--- /dev/null
+++ b/src/System Application/App/File System/src/Scenario/FileScenariosFactBox.Page.al
@@ -0,0 +1,42 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+///
+/// Lists of all scenarios assigned to an account.
+///
+page 9453 "File Scenarios FactBox"
+{
+ PageType = ListPart;
+ ApplicationArea = All;
+ Extensible = false;
+ SourceTable = "File Scenario";
+ InsertAllowed = false;
+ ModifyAllowed = false;
+ DeleteAllowed = false;
+ Editable = false;
+ ShowFilter = false;
+ LinksAllowed = false;
+ Permissions = tabledata "File Scenario" = r;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+
+ layout
+ {
+ area(Content)
+ {
+ repeater(ScenariosByFile)
+ {
+ field(Name; Format(Rec.Scenario))
+ {
+ ToolTip = 'Specifies the name of the file scenario.';
+ Caption = 'File scenario';
+ Editable = false;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/System Application/App/File System/src/Scenario/FileScenariosForAccount.Page.al b/src/System Application/App/File System/src/Scenario/FileScenariosForAccount.Page.al
new file mode 100644
index 0000000000..d9bc412c3a
--- /dev/null
+++ b/src/System Application/App/File System/src/Scenario/FileScenariosForAccount.Page.al
@@ -0,0 +1,68 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.FileSystem;
+
+///
+/// Displays the scenarios that could be linked to a provided file account.
+///
+page 9454 "File Scenarios for Account"
+{
+ PageType = List;
+ ApplicationArea = All;
+ Extensible = false;
+ SourceTable = "File Account Scenario";
+ InsertAllowed = false;
+ ModifyAllowed = false;
+ DeleteAllowed = false;
+ Editable = false;
+ ShowFilter = false;
+ LinksAllowed = false;
+ InherentPermissions = X;
+ InherentEntitlements = X;
+ UsageCategory = None;
+
+ layout
+ {
+ area(Content)
+ {
+ repeater(ScenariosByFile)
+ {
+ field(Name; Rec."Display Name")
+ {
+ ToolTip = 'Specifies the name of the file scenario.';
+ Caption = 'File scenario';
+ Editable = false;
+ }
+ }
+ }
+ }
+
+ internal procedure GetSelectedScenarios(var ResultFileAccountScenario: Record "File Account Scenario")
+ begin
+ ResultFileAccountScenario.Reset();
+ ResultFileAccountScenario.DeleteAll();
+
+ CurrPage.SetSelectionFilter(Rec);
+
+ if not Rec.FindSet() then
+ exit;
+
+ repeat
+ ResultFileAccountScenario.Copy(Rec);
+ ResultFileAccountScenario.Insert();
+ until Rec.Next() = 0;
+ end;
+
+ trigger OnOpenPage()
+ begin
+ FileScenarioImpl.GetAvailableScenariosForAccount(Rec, Rec);
+ Rec.SetCurrentKey("Display Name");
+ if Rec.FindFirst() then; // Set the selection to the first record
+ end;
+
+ var
+ FileScenarioImpl: Codeunit "File Scenario Impl.";
+}
\ No newline at end of file
diff --git a/src/System Application/Test Library/File System/Permissions/FileSystemAdmin.PermissionSet.al b/src/System Application/Test Library/File System/Permissions/FileSystemAdmin.PermissionSet.al
new file mode 100644
index 0000000000..ef304facff
--- /dev/null
+++ b/src/System Application/Test Library/File System/Permissions/FileSystemAdmin.PermissionSet.al
@@ -0,0 +1,19 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.TestLibraries.FileSystem;
+
+using System.FileSystem;
+
+permissionset 135810 "File System Admin"
+{
+ Assignable = true;
+ IncludedPermissionSets = "File System - Admin";
+
+ // Include Test Tables
+ Permissions =
+ tabledata "Test File Connector Setup" = RIMD,
+ tabledata "Test File Account" = RIMD;
+}
\ No newline at end of file
diff --git a/src/System Application/Test Library/File System/Permissions/FileSystemEdit.PermissionSet.al b/src/System Application/Test Library/File System/Permissions/FileSystemEdit.PermissionSet.al
new file mode 100644
index 0000000000..41cfad6fe2
--- /dev/null
+++ b/src/System Application/Test Library/File System/Permissions/FileSystemEdit.PermissionSet.al
@@ -0,0 +1,21 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.TestLibraries.FileSystem;
+
+using System.FileSystem;
+using System.Environment;
+
+permissionset 135811 "File System Edit"
+{
+ Assignable = true;
+ IncludedPermissionSets = "File System - Edit";
+
+ // Include Test Tables
+ Permissions =
+ tabledata "Test File Connector Setup" = RIMD,
+ tabledata "Test File Account" = RIMD, // Needed for the Record to get passed in Library Assert
+ tabledata "Scheduled Task" = rd; // Needed for enqueue tests
+}
\ No newline at end of file
diff --git a/src/System Application/Test Library/File System/app.json b/src/System Application/Test Library/File System/app.json
new file mode 100644
index 0000000000..7c313c3a72
--- /dev/null
+++ b/src/System Application/Test Library/File System/app.json
@@ -0,0 +1,39 @@
+{
+ "id": "f188754b-3ffb-443a-9507-f5fbdae3af2c",
+ "name": "File System Test Library",
+ "publisher": "Microsoft",
+ "brief": "Test library for the File System module",
+ "description": "Test library for the File System module",
+ "version": "26.0.0.0",
+ "privacyStatement": "https://go.microsoft.com/fwlink/?linkid=724009",
+ "EULA": "https://go.microsoft.com/fwlink/?linkid=2009120",
+ "help": "https://go.microsoft.com/fwlink/?linkid=2103698",
+ "url": "https://go.microsoft.com/fwlink/?linkid=724011",
+ "logo": "",
+ "dependencies": [
+ {
+ "id": "c9c54414-80c3-4cc9-98c6-589158882774",
+ "name": "File System",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ },
+ {
+ "id": "e7320ebb-08b3-4406-b1ec-b4927d3e280b",
+ "name": "Any",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ }
+ ],
+ "screenshots": [
+
+ ],
+ "platform": "26.0.0.0",
+ "idRanges": [
+ {
+ "from": 135810,
+ "to": 135819
+ }
+ ],
+ "contextSensitiveHelpUrl": "https://go.microsoft.com/fwlink/?linkid=2134520",
+ "target": "OnPrem"
+}
\ No newline at end of file
diff --git a/src/System Application/Test Library/File System/src/FileSystemTestLib.Codeunit.al b/src/System Application/Test Library/File System/src/FileSystemTestLib.Codeunit.al
new file mode 100644
index 0000000000..f21769e21b
--- /dev/null
+++ b/src/System Application/Test Library/File System/src/FileSystemTestLib.Codeunit.al
@@ -0,0 +1,25 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.TestLibraries.FileSystem;
+
+using System.FileSystem;
+
+codeunit 135813 "File System Test Lib."
+{
+ Permissions = tabledata "File Scenario" = rid;
+
+ procedure GetFileScenarioAccountIdAndFileConnector(Scenario: Enum "File Scenario"; var AccountId: Guid; var FileSystemConnector: Interface "File System Connector"): Boolean
+ var
+ FileScenarios: Record "File Scenario";
+ begin
+ if not FileScenarios.Get(Scenario) then
+ exit;
+
+ AccountId := FileScenarios."Account Id";
+ FileSystemConnector := FileScenarios.Connector;
+ exit(true);
+ end;
+}
\ No newline at end of file
diff --git a/src/System Application/Test Library/File System/src/Mock/FileConnectorMock.Codeunit.al b/src/System Application/Test Library/File System/src/Mock/FileConnectorMock.Codeunit.al
new file mode 100644
index 0000000000..f3094e4ab9
--- /dev/null
+++ b/src/System Application/Test Library/File System/src/Mock/FileConnectorMock.Codeunit.al
@@ -0,0 +1,119 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.TestLibraries.FileSystem;
+
+using System.FileSystem;
+using System.TestLibraries.Utilities;
+
+codeunit 135810 "File Connector Mock"
+{
+ var
+ Any: Codeunit Any;
+
+ procedure Initialize()
+ var
+ TestFileAccount: Record "Test File Account";
+ TestFileConnectorSetup: Record "Test File Connector Setup";
+ begin
+ TestFileConnectorSetup.DeleteAll();
+ TestFileConnectorSetup.Init();
+ TestFileConnectorSetup.Id := Any.GuidValue();
+ TestFileConnectorSetup."Fail On Send" := false;
+ TestFileConnectorSetup."Fail On Register Account" := false;
+ TestFileConnectorSetup."Unsuccessful Register" := false;
+ TestFileConnectorSetup.Insert();
+
+ TestFileAccount.DeleteAll();
+ end;
+
+ procedure GetAccounts(var FileAccount: Record "File Account")
+ var
+ TestFileAccount: Record "Test File Account";
+ begin
+ if TestFileAccount.FindSet() then
+ repeat
+ FileAccount.Init();
+ FileAccount."Account Id" := TestFileAccount.Id;
+ FileAccount.Name := TestFileAccount.Name;
+ FileAccount.Insert();
+ until TestFileAccount.Next() = 0;
+ end;
+
+ procedure AddAccount(var FileAccount: Record "File Account")
+ var
+ TestFileAccount: Record "Test File Account";
+ begin
+ TestFileAccount.Id := Any.GuidValue();
+ TestFileAccount.Name := CopyStr(Any.AlphanumericText(250), 1, 250);
+ TestFileAccount.Insert();
+
+ FileAccount."Account Id" := TestFileAccount.Id;
+ FileAccount.Name := TestFileAccount.Name;
+ FileAccount.Connector := Enum::"File System Connector"::"Test File System Connector";
+ end;
+
+ procedure AddAccount(var Id: Guid)
+ var
+ TestFileAccount: Record "Test File Account";
+ begin
+ TestFileAccount.Id := Any.GuidValue();
+ TestFileAccount.Name := CopyStr(Any.AlphanumericText(250), 1, 250);
+ TestFileAccount.Insert();
+
+ Id := TestFileAccount.Id;
+ end;
+
+ procedure FailOnSend(): Boolean
+ var
+ TestFileConnectorSetup: Record "Test File Connector Setup";
+ begin
+ TestFileConnectorSetup.FindFirst();
+ exit(TestFileConnectorSetup."Fail On Send");
+ end;
+
+ procedure FailOnSend(Fail: Boolean)
+ var
+ TestFileConnectorSetup: Record "Test File Connector Setup";
+ begin
+ TestFileConnectorSetup.FindFirst();
+ TestFileConnectorSetup."Fail On Send" := Fail;
+ TestFileConnectorSetup.Modify();
+ end;
+
+ procedure FailOnRegisterAccount(): Boolean
+ var
+ TestFileConnectorSetup: Record "Test File Connector Setup";
+ begin
+ TestFileConnectorSetup.FindFirst();
+ exit(TestFileConnectorSetup."Fail On Register Account");
+ end;
+
+ procedure FailOnRegisterAccount(Fail: Boolean)
+ var
+ TestFileConnectorSetup: Record "Test File Connector Setup";
+ begin
+ TestFileConnectorSetup.FindFirst();
+ TestFileConnectorSetup."Fail On Register Account" := Fail;
+ TestFileConnectorSetup.Modify();
+ end;
+
+ procedure UnsuccessfulRegister(): Boolean
+ var
+ TestFileConnectorSetup: Record "Test File Connector Setup";
+ begin
+ TestFileConnectorSetup.FindFirst();
+ exit(TestFileConnectorSetup."Unsuccessful Register");
+ end;
+
+ procedure UnsuccessfulRegister(Fail: Boolean)
+ var
+ TestFileConnectorSetup: Record "Test File Connector Setup";
+ begin
+ TestFileConnectorSetup.FindFirst();
+ TestFileConnectorSetup."Unsuccessful Register" := Fail;
+ TestFileConnectorSetup.Modify();
+ end;
+}
\ No newline at end of file
diff --git a/src/System Application/Test Library/File System/src/Mock/FileScenarioMock.Codeunit.al b/src/System Application/Test Library/File System/src/Mock/FileScenarioMock.Codeunit.al
new file mode 100644
index 0000000000..b6afc6709e
--- /dev/null
+++ b/src/System Application/Test Library/File System/src/Mock/FileScenarioMock.Codeunit.al
@@ -0,0 +1,31 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.TestLibraries.FileSystem;
+
+using System.FileSystem;
+
+codeunit 135811 "File Scenario Mock"
+{
+ Permissions = tabledata "File Scenario" = rid;
+
+ procedure AddMapping(FileScenario: Enum "File Scenario"; AccountId: Guid; Connector: Enum "File System Connector")
+ var
+ Scenario: Record "File Scenario";
+ begin
+ Scenario.Scenario := FileScenario;
+ Scenario."Account Id" := AccountId;
+ Scenario.Connector := Connector;
+
+ Scenario.Insert();
+ end;
+
+ procedure DeleteAllMappings()
+ var
+ Scenario: Record "File Scenario";
+ begin
+ Scenario.DeleteAll();
+ end;
+}
\ No newline at end of file
diff --git a/src/System Application/Test Library/File System/src/Mock/FileSystemAccSelectionMock.Codeunit.al b/src/System Application/Test Library/File System/src/Mock/FileSystemAccSelectionMock.Codeunit.al
new file mode 100644
index 0000000000..f69d44a061
--- /dev/null
+++ b/src/System Application/Test Library/File System/src/Mock/FileSystemAccSelectionMock.Codeunit.al
@@ -0,0 +1,44 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.Test.FileSystem;
+
+using System.FileSystem;
+
+///
+/// Used to mock selected file accounts on File Accounts page.
+///
+codeunit 135812 "File System Acc Selection Mock"
+{
+ EventSubscriberInstance = Manual;
+
+ var
+ SelectionFilterLbl: Label '%1|%2', Locked = true;
+
+ procedure SelectAccount(AccountId: Guid)
+ begin
+ SelectedAccounts.Add(AccountId);
+ end;
+
+ [EventSubscriber(ObjectType::Codeunit, Codeunit::"File Account Impl.", 'OnAfterSetSelectionFilter', '', false, false)]
+ local procedure SelectAccounts(var FileAccount: Record "File Account")
+ var
+ AccountId: Guid;
+ SelectionFilter: Text;
+ begin
+ FileAccount.Reset();
+
+ foreach AccountId in SelectedAccounts do
+ SelectionFilter := StrSubstNo(SelectionFilterLbl, SelectionFilter, AccountId);
+
+ SelectionFilter := DelChr(SelectionFilter, '<>', '|'); // remove trailing and leading pipes
+
+ if SelectionFilter <> '' then
+ FileAccount.SetFilter("Account Id", SelectionFilter);
+ end;
+
+ var
+ SelectedAccounts: List of [Guid];
+}
\ No newline at end of file
diff --git a/src/System Application/Test Library/File System/src/TestFileAccount.Table.al b/src/System Application/Test Library/File System/src/TestFileAccount.Table.al
new file mode 100644
index 0000000000..c0320fe4ff
--- /dev/null
+++ b/src/System Application/Test Library/File System/src/TestFileAccount.Table.al
@@ -0,0 +1,32 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.TestLibraries.FileSystem;
+
+table 135810 "Test File Account"
+{
+ DataClassification = SystemMetadata;
+ ReplicateData = false;
+
+ fields
+ {
+ field(1; Id; Guid)
+ {
+ Caption = 'Primary Key';
+ }
+ field(2; Name; Text[250])
+ {
+ Caption = 'Name';
+ }
+ }
+
+ keys
+ {
+ key(PK; Id)
+ {
+ Clustered = true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/System Application/Test Library/File System/src/TestFileConnectorSetup.Table.al b/src/System Application/Test Library/File System/src/TestFileConnectorSetup.Table.al
new file mode 100644
index 0000000000..edf6e6ae24
--- /dev/null
+++ b/src/System Application/Test Library/File System/src/TestFileConnectorSetup.Table.al
@@ -0,0 +1,40 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.TestLibraries.FileSystem;
+
+table 135811 "Test File Connector Setup"
+{
+ DataClassification = SystemMetadata;
+ ReplicateData = false;
+
+ fields
+ {
+ field(1; Id; Guid)
+ {
+ Caption = 'Primary Key';
+ }
+ field(2; "Fail On Send"; Boolean)
+ {
+ Caption = 'Fail On Send';
+ }
+ field(3; "Fail On Register Account"; Boolean)
+ {
+ Caption = 'Fail On Register Account';
+ }
+ field(4; "Unsuccessful Register"; Boolean)
+ {
+ Caption = 'Unsuccessful Register';
+ }
+ }
+
+ keys
+ {
+ key(PK; Id)
+ {
+ Clustered = true;
+ }
+ }
+}
diff --git a/src/System Application/Test Library/File System/src/TestFileScenario.EnumExt.al b/src/System Application/Test Library/File System/src/TestFileScenario.EnumExt.al
new file mode 100644
index 0000000000..ecd868e9d7
--- /dev/null
+++ b/src/System Application/Test Library/File System/src/TestFileScenario.EnumExt.al
@@ -0,0 +1,15 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.TestLibraries.FileSystem;
+
+using System.FileSystem;
+
+enumextension 135810 "Test File Scenario" extends "File Scenario"
+{
+ value(135810; "Test File Scenario")
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/System Application/Test Library/File System/src/TestFileSystemConnector.Codeunit.al b/src/System Application/Test Library/File System/src/TestFileSystemConnector.Codeunit.al
new file mode 100644
index 0000000000..3f61f7e0e3
--- /dev/null
+++ b/src/System Application/Test Library/File System/src/TestFileSystemConnector.Codeunit.al
@@ -0,0 +1,110 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.TestLibraries.FileSystem;
+
+using System.FileSystem;
+
+codeunit 135814 "Test File System Connector" implements "File System Connector"
+{
+ procedure ListFiles(AccountId: Guid; Path: Text; FilePaginationData: Codeunit "File Pagination Data"; var FileAccountContent: Record "File Account Content" temporary);
+ begin
+ FileAccountContent.Init();
+ FileAccountContent.Type := FileAccountContent.Type::Directory;
+ FileAccountContent.Name := 'Test Folder';
+ FileAccountContent.Insert();
+
+ FileAccountContent.Init();
+ FileAccountContent.Type := FileAccountContent.Type::File;
+ FileAccountContent.Name := 'Test.pdf';
+ FileAccountContent.Insert();
+ end;
+
+ procedure GetFile(AccountId: Guid; Path: Text; Stream: InStream);
+ begin
+ end;
+
+ procedure CreateFile(AccountId: Guid; Path: Text; Stream: InStream);
+ begin
+ end;
+
+ procedure CopyFile(AccountId: Guid; SourcePath: Text; TargetPath: Text);
+ begin
+ end;
+
+ procedure MoveFile(AccountId: Guid; SourcePath: Text; TargetPath: Text);
+ begin
+ end;
+
+ procedure FileExists(AccountId: Guid; Path: Text): Boolean;
+ begin
+ end;
+
+ procedure DeleteFile(AccountId: Guid; Path: Text);
+ begin
+ end;
+
+ procedure ListDirectories(AccountId: Guid; Path: Text; FilePaginationData: Codeunit "File Pagination Data"; var FileAccountContent: Record "File Account Content" temporary);
+ begin
+ end;
+
+ procedure CreateDirectory(AccountId: Guid; Path: Text);
+ begin
+ end;
+
+ procedure DirectoryExists(AccountId: Guid; Path: Text): Boolean;
+ begin
+ end;
+
+ procedure DeleteDirectory(AccountId: Guid; Path: Text);
+ begin
+ end;
+
+ procedure GetAccounts(var Accounts: Record "File Account")
+ begin
+ FileConnectorMock.GetAccounts(Accounts);
+ end;
+
+ procedure ShowAccountInformation(AccountId: Guid)
+ begin
+ Message('Showing information for account: %1', AccountId);
+ end;
+
+ procedure RegisterAccount(var FileAccount: Record "File Account"): Boolean
+ var
+ begin
+ if FileConnectorMock.FailOnRegisterAccount() then
+ Error('Failed to register account');
+
+ if FileConnectorMock.UnsuccessfulRegister() then
+ exit(false);
+
+ FileAccount."Account Id" := CreateGuid();
+ FileAccount.Name := 'Test account';
+
+ exit(true);
+ end;
+
+ procedure DeleteAccount(AccountId: Guid): Boolean
+ var
+ TestFileAccount: Record "Test File Account";
+ begin
+ if TestFileAccount.Get(AccountId) then
+ exit(TestFileAccount.Delete());
+ exit(false);
+ end;
+
+ procedure GetLogoAsBase64(): Text
+ begin
+ end;
+
+ procedure GetDescription(): Text[250]
+ begin
+ exit('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis ornare ante a est commodo interdum. Pellentesque eu diam maximus, faucibus neque ut, viverra leo. Praesent ullamcorper nibh ut pretium dapibus. Nullam eu dui libero. Etiam ac cursus metus.')
+ end;
+
+ var
+ FileConnectorMock: Codeunit "File Connector Mock";
+}
\ No newline at end of file
diff --git a/src/System Application/Test Library/File System/src/TestFileSystemConnector.EnumExt.al b/src/System Application/Test Library/File System/src/TestFileSystemConnector.EnumExt.al
new file mode 100644
index 0000000000..bc58e63b3a
--- /dev/null
+++ b/src/System Application/Test Library/File System/src/TestFileSystemConnector.EnumExt.al
@@ -0,0 +1,16 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.TestLibraries.FileSystem;
+
+using System.FileSystem;
+
+enumextension 135815 "Test File System Connector" extends "File System Connector"
+{
+ value(135810; "Test File System Connector")
+ {
+ Implementation = "File System Connector" = "Test File System Connector";
+ }
+}
\ No newline at end of file
diff --git a/src/System Application/Test/File System/app.json b/src/System Application/Test/File System/app.json
new file mode 100644
index 0000000000..258df260b2
--- /dev/null
+++ b/src/System Application/Test/File System/app.json
@@ -0,0 +1,75 @@
+{
+ "id": "fff6eee5-083f-4f07-9a49-e34f7e2aad77",
+ "name": "File System Test",
+ "publisher": "Microsoft",
+ "brief": "Tests for the File System module",
+ "description": "Tests for the File System module",
+ "version": "26.0.0.0",
+ "privacyStatement": "https://go.microsoft.com/fwlink/?linkid=724009",
+ "EULA": "https://go.microsoft.com/fwlink/?linkid=2009120",
+ "help": "https://go.microsoft.com/fwlink/?linkid=2103698",
+ "url": "https://go.microsoft.com/fwlink/?linkid=724011",
+ "logo": "",
+ "dependencies": [
+ {
+ "id": "c9c54414-80c3-4cc9-98c6-589158882774",
+ "name": "File System",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ },
+ {
+ "id": "f188754b-3ffb-443a-9507-f5fbdae3af2c",
+ "name": "File System Test Library",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ },
+ {
+ "id": "5095f467-0a01-4b99-99d1-9ff1237d286f",
+ "name": "Library Variable Storage",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ },
+ {
+ "id": "e31ad830-3d46-472e-afeb-1d3d35247943",
+ "name": "BLOB Storage",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ },
+ {
+ "id": "0846d207-5dec-4c1b-afd8-6a25e1e14b9d",
+ "name": "Base64 Convert",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ },
+ {
+ "id": "dd0be2ea-f733-4d65-bb34-a28f4624fb14",
+ "name": "Library Assert",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ },
+ {
+ "id": "e7320ebb-08b3-4406-b1ec-b4927d3e280b",
+ "name": "Any",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ },
+ {
+ "id": "40860557-a18d-42ad-aecb-22b7dd80dc80",
+ "name": "Permissions Mock",
+ "publisher": "Microsoft",
+ "version": "26.0.0.0"
+ }
+ ],
+ "screenshots": [
+
+ ],
+ "platform": "26.0.0.0",
+ "idRanges": [
+ {
+ "from": 134750,
+ "to": 134754
+ }
+ ],
+ "contextSensitiveHelpUrl": "https://go.microsoft.com/fwlink/?linkid=2134520",
+ "target": "OnPrem"
+}
\ No newline at end of file
diff --git a/src/System Application/Test/File System/src/FileAccountsTest.Codeunit.al b/src/System Application/Test/File System/src/FileAccountsTest.Codeunit.al
new file mode 100644
index 0000000000..d28d0f07e3
--- /dev/null
+++ b/src/System Application/Test/File System/src/FileAccountsTest.Codeunit.al
@@ -0,0 +1,502 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.Test.FileSystem;
+
+using System.FileSystem;
+using System.TestLibraries.FileSystem;
+using System.TestLibraries.Utilities;
+using System.TestLibraries.Security.AccessControl;
+
+codeunit 134750 "File Accounts Test"
+{
+ Subtype = Test;
+ TestPermissions = Disabled;
+
+ var
+ Assert: Codeunit "Library Assert";
+ PermissionsMock: Codeunit "Permissions Mock";
+ AccountToSelect: Guid;
+
+ [Test]
+ [Scope('OnPrem')]
+ [TransactionModel(TransactionModel::AutoRollback)]
+ procedure AccountsAppearOnThePageTest()
+ var
+ FileAccount: Record "File Account";
+ FileConnectorMock: Codeunit "File Connector Mock";
+ AccountsPage: TestPage "File Accounts";
+ begin
+ // [Scenario] When there's a File account for a connector, it appears on the accounts page
+
+ // [Given] A File account
+ FileConnectorMock.Initialize();
+ FileConnectorMock.AddAccount(FileAccount);
+
+ PermissionsMock.Set('File System Edit');
+
+ // [When] The accounts page is open
+ AccountsPage.OpenView();
+
+ // [Then] The file entry is visible on the page
+ Assert.IsTrue(AccountsPage.GoToKey(FileAccount."Account Id", FileAccount.Connector), 'The File account should be on the page');
+
+ Assert.AreEqual(FileAccount.Name, Format(AccountsPage.NameField), 'The account name on the page is wrong');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ [TransactionModel(TransactionModel::AutoRollback)]
+ procedure TwoAccountsAppearOnThePageTest()
+ var
+ FirstFileAccount, SecondFileAccount : Record "File Account";
+ FileConnectorMock: Codeunit "File Connector Mock";
+ AccountsPage: TestPage "File Accounts";
+ begin
+ // [Scenario] When there's a File account for a connector, it appears on the accounts page
+
+ // [Given] Two File accounts
+ FileConnectorMock.Initialize();
+ FileConnectorMock.AddAccount(FirstFileAccount);
+ FileConnectorMock.AddAccount(SecondFileAccount);
+
+ PermissionsMock.Set('File System Edit');
+
+ // [When] The accounts page is open
+ AccountsPage.OpenView();
+
+ // [Then] The file entries are visible on the page
+ Assert.IsTrue(AccountsPage.GoToKey(FirstFileAccount."Account Id", Enum::"File System Connector"::"Test File System Connector"), 'The first File account should be on the page');
+ Assert.AreEqual(FirstFileAccount.Name, Format(AccountsPage.NameField), 'The first account name on the page is wrong');
+
+ Assert.IsTrue(AccountsPage.GoToKey(SecondFileAccount."Account Id", Enum::"File System Connector"::"Test File System Connector"), 'The second File account should be on the page');
+ Assert.AreEqual(SecondFileAccount.Name, Format(AccountsPage.NameField), 'The second account name on the page is wrong');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ [TransactionModel(TransactionModel::AutoRollback)]
+ procedure AddNewAccountTest()
+ var
+ FileConnectorMock: Codeunit "File Connector Mock";
+ AccountWizardPage: TestPage "File Account Wizard";
+ begin
+ // [SCENARIO] A new Account can be added through the Account Wizard
+ PermissionsMock.Set('File System Admin');
+
+ FileConnectorMock.Initialize();
+
+ // [WHEN] The AddAccount action is invoked
+ AccountWizardPage.Trap();
+ Page.Run(Page::"File Account Wizard");
+
+ // [WHEN] The next field is invoked
+ AccountWizardPage.Next.Invoke();
+
+ // [THEN] The connector screen is shown and the test connector is shown
+ Assert.IsTrue(AccountWizardPage.Name.Visible(), 'Connector Name should be visible');
+ Assert.IsTrue(AccountWizardPage.Details.Visible(), 'Connector Details should be visible');
+
+ Assert.IsTrue(AccountWizardPage.GoToKey(Enum::"File System Connector"::"Test File System Connector"), 'Test File connector was not shown in the page');
+
+ // [WHEN] The Name field is drilled down
+ AccountWizardPage.Next.Invoke();
+
+ // [THEN] The Connector registers the Account and the last page is shown
+ Assert.AreEqual(AccountWizardPage.NameField.Value(), 'Test account', 'A different name was expected');
+ Assert.AreEqual(AccountWizardPage.DefaultField.AsBoolean(), true, 'Default should be set to true if it''s the first account to be set up');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ [TransactionModel(TransactionModel::AutoRollback)]
+ [HandlerFunctions('AddAccountModalPageHandler')]
+ procedure AddNewAccountActionRunsPageInModalTest()
+ var
+ AccountsPage: TestPage "File Accounts";
+ begin
+ // [SCENARIO] The add Account action open the Account Wizard page in modal mode
+ PermissionsMock.Set('File System Admin');
+
+ AccountsPage.OpenView();
+ // [WHEN] The AddAccount action is invoked
+ AccountsPage.AddAccount.Invoke();
+
+ // Verify with AddAccountModalPageHandler
+ end;
+
+ [Test]
+ procedure GetAllAccountsTest()
+ var
+ FileAccountBuffer, FileAccounts : Record "File Account";
+ FileConnectorMock: Codeunit "File Connector Mock";
+ FileAccount: Codeunit "File Account";
+ begin
+ // [SCENARIO] GetAllAccounts retrieves all the registered accounts
+
+ // [GIVEN] A connector is installed and no account is added
+ FileConnectorMock.Initialize();
+
+ PermissionsMock.Set('File System Edit');
+
+ // [WHEN] GetAllAccounts is called
+ FileAccount.GetAllAccounts(FileAccounts);
+
+ // [THEN] The returned record is empty (there are no registered accounts)
+ Assert.IsTrue(FileAccounts.IsEmpty(), 'Record should be empty');
+
+ // [GIVEN] An account is added to the connector
+ FileConnectorMock.AddAccount(FileAccountBuffer);
+
+ // [WHEN] GetAllAccounts is called
+ FileAccount.GetAllAccounts(FileAccounts);
+
+ // [THEN] The returned record is not empty and the values are as expected
+ Assert.AreEqual(1, FileAccounts.Count(), 'Record should not be empty');
+ FileAccounts.FindFirst();
+ Assert.AreEqual(FileAccountBuffer."Account Id", FileAccounts."Account Id", 'Wrong account ID');
+ Assert.AreEqual(Enum::"File System Connector"::"Test File System Connector", FileAccounts.Connector, 'Wrong connector');
+ Assert.AreEqual(FileAccountBuffer.Name, FileAccounts.Name, 'Wrong account name');
+ end;
+
+ [Test]
+ procedure IsAnyAccountRegisteredTest()
+ var
+ FileAccount: Codeunit "File Account";
+ FileConnectorMock: Codeunit "File Connector Mock";
+ AccountId: Guid;
+ begin
+ // [SCENARIO] File Account Exists works as expected
+
+ // [GIVEN] A connector is installed and no account is added
+ FileConnectorMock.Initialize();
+
+ PermissionsMock.Set('File System Edit');
+
+ // [WHEN] Calling IsAnyAccountRegistered
+ // [THEN] it evaluates to false
+ Assert.IsFalse(FileAccount.IsAnyAccountRegistered(), 'There should be no registered accounts');
+
+ // [WHEN] An File account is added
+ FileConnectorMock.AddAccount(AccountId);
+
+ // [WHEN] Calling IsAnyAccountRegistered
+ // [THEN] it evaluates to true
+ Assert.IsTrue(FileAccount.IsAnyAccountRegistered(), 'There should be a registered account');
+ end;
+
+ [Test]
+ [HandlerFunctions('ConfirmYesHandler')]
+ procedure DeleteAllAccountsTest()
+ var
+ FileConnectorMock: Codeunit "File Connector Mock";
+ FileAccountsSelectionMock: Codeunit "File System Acc Selection Mock";
+ FirstAccountId, SecondAccountId, ThirdAccountId : Guid;
+ FileAccountsTestPage: TestPage "File Accounts";
+ begin
+ // [SCENARIO] When all accounts are deleted, the File Accounts page is empty
+ PermissionsMock.Set('File System Admin');
+
+ // [GIVEN] A connector is installed and three account are added
+ FileConnectorMock.Initialize();
+ FileConnectorMock.AddAccount(FirstAccountId);
+ FileConnectorMock.AddAccount(SecondAccountId);
+ FileConnectorMock.AddAccount(ThirdAccountId);
+
+ // [WHEN] Open the File Accounts page
+ FileAccountsTestPage.OpenView();
+
+ // [WHEN] Select all of the accounts
+ BindSubscription(FileAccountsSelectionMock);
+ FileAccountsSelectionMock.SelectAccount(FirstAccountId);
+ FileAccountsSelectionMock.SelectAccount(SecondAccountId);
+ FileAccountsSelectionMock.SelectAccount(ThirdAccountId);
+
+ // [WHEN] Delete action is invoked and the action is confirmed (see ConfirmYesHandler)
+ FileAccountsTestPage.Delete.Invoke();
+
+ // [THEN] The page is empty
+ Assert.IsFalse(FileAccountsTestPage.First(), 'The File Accounts page should be empty');
+ end;
+
+ [Test]
+ [HandlerFunctions('ConfirmNoHandler')]
+ procedure DeleteAllAccountsCancelTest()
+ var
+ FileConnectorMock: Codeunit "File Connector Mock";
+ FileAccountsSelectionMock: Codeunit "File System Acc Selection Mock";
+ FirstAccountId, SecondAccountId, ThirdAccountId : Guid;
+ FileAccountsTestPage: TestPage "File Accounts";
+ begin
+ // [SCENARIO] When all accounts are about to be deleted but the action in canceled, the File Accounts page contains all of them.
+ PermissionsMock.Set('File System Admin');
+
+ // [GIVEN] A connector is installed and three account are added
+ FileConnectorMock.Initialize();
+ FileConnectorMock.AddAccount(FirstAccountId);
+ FileConnectorMock.AddAccount(SecondAccountId);
+ FileConnectorMock.AddAccount(ThirdAccountId);
+
+ // [WHEN] Open the File Accounts page
+ FileAccountsTestPage.OpenView();
+
+ // [WHEN] Select all of the accounts
+ BindSubscription(FileAccountsSelectionMock);
+ FileAccountsSelectionMock.SelectAccount(FirstAccountId);
+ FileAccountsSelectionMock.SelectAccount(SecondAccountId);
+ FileAccountsSelectionMock.SelectAccount(ThirdAccountId);
+
+ // [WHEN] Delete action is invoked and the action is not confirmed (see ConfirmNoHandler)
+ FileAccountsTestPage.Delete.Invoke();
+
+ // [THEN] All of the accounts are on the page
+ Assert.IsTrue(FileAccountsTestPage.GoToKey(FirstAccountId, Enum::"File System Connector"::"Test File System Connector"), 'The first File account should be on the page');
+ Assert.IsTrue(FileAccountsTestPage.GoToKey(SecondAccountId, Enum::"File System Connector"::"Test File System Connector"), 'The second File account should be on the page');
+ Assert.IsTrue(FileAccountsTestPage.GoToKey(ThirdAccountId, Enum::"File System Connector"::"Test File System Connector"), 'The third File account should be on the page');
+ end;
+
+ [Test]
+ [HandlerFunctions('ConfirmYesHandler')]
+ procedure DeleteSomeAccountsTest()
+ var
+ FileConnectorMock: Codeunit "File Connector Mock";
+ FileAccountsSelectionMock: Codeunit "File System Acc Selection Mock";
+ FirstAccountId, SecondAccountId, ThirdAccountId : Guid;
+ FileAccountsTestPage: TestPage "File Accounts";
+ begin
+ // [SCENARIO] When some accounts are deleted, they cannot be found on the page
+ PermissionsMock.Set('File System Admin');
+
+ // [GIVEN] A connector is installed and three account are added
+ FileConnectorMock.Initialize();
+ FileConnectorMock.AddAccount(FirstAccountId);
+ FileConnectorMock.AddAccount(SecondAccountId);
+ FileConnectorMock.AddAccount(ThirdAccountId);
+
+ // [WHEN] Open the File Accounts page
+ FileAccountsTestPage.OpenView();
+
+ // [WHEN] Select only two of the accounts
+ BindSubscription(FileAccountsSelectionMock);
+ FileAccountsSelectionMock.SelectAccount(FirstAccountId);
+ FileAccountsSelectionMock.SelectAccount(ThirdAccountId);
+
+ // [WHEN] Delete action is invoked and the action is confirmed (see ConfirmYesHandler)
+ FileAccountsTestPage.Delete.Invoke();
+
+ // [THEN] The deleted accounts are not on the page, the non-deleted accounts are on the page.
+ Assert.IsFalse(FileAccountsTestPage.GoToKey(FirstAccountId, Enum::"File System Connector"::"Test File System Connector"), 'The first File account should not be on the page');
+ Assert.IsTrue(FileAccountsTestPage.GoToKey(SecondAccountId, Enum::"File System Connector"::"Test File System Connector"), 'The second File account should be on the page');
+ Assert.IsFalse(FileAccountsTestPage.GoToKey(ThirdAccountId, Enum::"File System Connector"::"Test File System Connector"), 'The third File account should not be on the page');
+ end;
+
+ [Test]
+ [HandlerFunctions('ConfirmYesHandler')]
+ procedure DeleteNonDefaultAccountTest()
+ var
+ SecondAccount: Record "File Account";
+ FileConnectorMock: Codeunit "File Connector Mock";
+ FileAccountsSelectionMock: Codeunit "File System Acc Selection Mock";
+ FileScenario: Codeunit "File Scenario";
+ FirstAccountId, ThirdAccountId : Guid;
+ FileAccountsTestPage: TestPage "File Accounts";
+ begin
+ // [SCENARIO] When the a non default account is deleted, the user is not prompted to choose a new default account.
+ PermissionsMock.Set('File System Admin');
+
+ // [GIVEN] A connector is installed and three account are added
+ FileConnectorMock.Initialize();
+ FileConnectorMock.AddAccount(FirstAccountId);
+ FileConnectorMock.AddAccount(SecondAccount);
+ FileConnectorMock.AddAccount(ThirdAccountId);
+
+ // [GIVEN] The second account is set as default
+ FileScenario.SetDefaultFileAccount(SecondAccount);
+
+ // [WHEN] Open the File Accounts page
+ FileAccountsTestPage.OpenView();
+
+ // [WHEN] Select a non-default account
+ BindSubscription(FileAccountsSelectionMock);
+ FileAccountsSelectionMock.SelectAccount(FirstAccountId);
+
+ // [WHEN] Delete action is invoked and the action is confirmed (see ConfirmYesHandler)
+ FileAccountsTestPage.Delete.Invoke();
+
+ // [THEN] The deleted accounts are not on the page, the non-deleted accounts are on the page.
+ Assert.IsFalse(FileAccountsTestPage.GoToKey(FirstAccountId, Enum::"File System Connector"::"Test File System Connector"), 'The first File account should not be on the page');
+
+ Assert.IsTrue(FileAccountsTestPage.GoToKey(SecondAccount."Account Id", Enum::"File System Connector"::"Test File System Connector"), 'The second File account should be on the page');
+ Assert.IsTrue(GetDefaultFieldValueAsBoolean(FileAccountsTestPage.DefaultField.Value), 'The second account should be marked as default');
+
+ Assert.IsTrue(FileAccountsTestPage.GoToKey(ThirdAccountId, Enum::"File System Connector"::"Test File System Connector"), 'The third File account should be on the page');
+ Assert.IsFalse(GetDefaultFieldValueAsBoolean(FileAccountsTestPage.DefaultField.Value), 'The third account should not be marked as default');
+ end;
+
+ [Test]
+ [HandlerFunctions('ConfirmYesHandler')]
+ procedure DeleteDefaultAccountTest()
+ var
+ SecondAccount: Record "File Account";
+ FileConnectorMock: Codeunit "File Connector Mock";
+ FileAccountsSelectionMock: Codeunit "File System Acc Selection Mock";
+ FileScenario: Codeunit "File Scenario";
+ FirstAccountId, ThirdAccountId : Guid;
+ FileAccountsTestPage: TestPage "File Accounts";
+ begin
+ // [SCENARIO] When the default account is deleted, the user is not prompted to choose a new default account if there's only one account left
+ PermissionsMock.Set('File System Admin');
+
+ // [GIVEN] A connector is installed and three account are added
+ FileConnectorMock.Initialize();
+ FileConnectorMock.AddAccount(FirstAccountId);
+ FileConnectorMock.AddAccount(SecondAccount);
+ FileConnectorMock.AddAccount(ThirdAccountId);
+
+ // [GIVEN] The second account is set as default
+ FileScenario.SetDefaultFileAccount(SecondAccount);
+
+ // [WHEN] Open the File Accounts page
+ FileAccountsTestPage.OpenView();
+
+ // [WHEN] Select accounts including the default one
+ BindSubscription(FileAccountsSelectionMock);
+ FileAccountsSelectionMock.SelectAccount(SecondAccount."Account Id");
+ FileAccountsSelectionMock.SelectAccount(ThirdAccountId);
+
+ // [WHEN] Delete action is invoked and the action is confirmed (see ConfirmYesHandler)
+ FileAccountsTestPage.Delete.Invoke();
+
+ // [THEN] The deleted accounts are not on the page, the non-deleted accounts are on the page.
+ Assert.IsTrue(FileAccountsTestPage.GoToKey(FirstAccountId, Enum::"File System Connector"::"Test File System Connector"), 'The first File account should be on the page');
+ Assert.IsTrue(GetDefaultFieldValueAsBoolean(FileAccountsTestPage.DefaultField.Value), 'The first account should be marked as default');
+
+ Assert.IsFalse(FileAccountsTestPage.GoToKey(SecondAccount."Account Id", Enum::"File System Connector"::"Test File System Connector"), 'The second File account should not be on the page');
+ Assert.IsFalse(FileAccountsTestPage.GoToKey(ThirdAccountId, Enum::"File System Connector"::"Test File System Connector"), 'The third File account should not be on the page');
+ end;
+
+ [Test]
+ [HandlerFunctions('ConfirmYesHandler,ChooseNewDefaultAccountCancelHandler')]
+ procedure DeleteDefaultAccountPromptNewAccountCancelTest()
+ var
+ SecondAccount: Record "File Account";
+ FileConnectorMock: Codeunit "File Connector Mock";
+ FileAccountsSelectionMock: Codeunit "File System Acc Selection Mock";
+ FileScenario: Codeunit "File Scenario";
+ FirstAccountId, ThirdAccountId : Guid;
+ FileAccountsTestPage: TestPage "File Accounts";
+ begin
+ // [SCENARIO] When the default account is deleted, the user is prompted to choose a new default account but they cancel.
+ PermissionsMock.Set('File System Admin');
+
+ // [GIVEN] A connector is installed and three account are added
+ FileConnectorMock.Initialize();
+ FileConnectorMock.AddAccount(FirstAccountId);
+ FileConnectorMock.AddAccount(SecondAccount);
+ FileConnectorMock.AddAccount(ThirdAccountId);
+
+ // [GIVEN] The second account is set as default
+ FileScenario.SetDefaultFileAccount(SecondAccount);
+
+ // [WHEN] Open the File Accounts page
+ FileAccountsTestPage.OpenView();
+
+ // [WHEN] Select the default account
+ BindSubscription(FileAccountsSelectionMock);
+ FileAccountsSelectionMock.SelectAccount(SecondAccount."Account Id");
+
+ // [WHEN] Delete action is invoked and the action is confirmed (see ConfirmYesHandler)
+ AccountToSelect := ThirdAccountId; // The third account is selected as the new default account
+ FileAccountsTestPage.Delete.Invoke();
+
+ // [THEN] The default account was deleted and there is no new default account
+ Assert.IsTrue(FileAccountsTestPage.GoToKey(FirstAccountId, Enum::"File System Connector"::"Test File System Connector"), 'The first File account should be on the page');
+ Assert.IsFalse(GetDefaultFieldValueAsBoolean(FileAccountsTestPage.DefaultField.Value), 'The third account should not be marked as default');
+
+ Assert.IsFalse(FileAccountsTestPage.GoToKey(SecondAccount."Account Id", Enum::"File System Connector"::"Test File System Connector"), 'The second File account should not be on the page');
+
+ Assert.IsTrue(FileAccountsTestPage.GoToKey(ThirdAccountId, Enum::"File System Connector"::"Test File System Connector"), 'The third File account should be on the page');
+ Assert.IsFalse(GetDefaultFieldValueAsBoolean(FileAccountsTestPage.DefaultField.Value), 'The third account should not be marked as default');
+ end;
+
+ [Test]
+ [HandlerFunctions('ConfirmYesHandler,ChooseNewDefaultAccountHandler')]
+ procedure DeleteDefaultAccountPromptNewAccountTest()
+ var
+ SecondAccount: Record "File Account";
+ FileConnectorMock: Codeunit "File Connector Mock";
+ FileAccountsSelectionMock: Codeunit "File System Acc Selection Mock";
+ FileScenario: Codeunit "File Scenario";
+ FirstAccountId, ThirdAccountId : Guid;
+ FileAccountsTestPage: TestPage "File Accounts";
+ begin
+ // [SCENARIO] When the default account is deleted, the user is prompted to choose a new default account
+ PermissionsMock.Set('File System Admin');
+
+ // [GIVEN] A connector is installed and three account are added
+ FileConnectorMock.Initialize();
+ FileConnectorMock.AddAccount(FirstAccountId);
+ FileConnectorMock.AddAccount(SecondAccount);
+ FileConnectorMock.AddAccount(ThirdAccountId);
+
+ // [GIVEN] The second account is set as default
+ FileScenario.SetDefaultFileAccount(SecondAccount);
+
+ // [WHEN] Open the File Accounts page
+ FileAccountsTestPage.OpenView();
+
+ // [WHEN] Select the default account
+ BindSubscription(FileAccountsSelectionMock);
+ FileAccountsSelectionMock.SelectAccount(SecondAccount."Account Id");
+
+ // [WHEN] Delete action is invoked and the action is confirmed (see ConfirmYesHandler)
+ AccountToSelect := ThirdAccountId; // The third account is selected as the new default account
+ FileAccountsTestPage.Delete.Invoke();
+
+ // [THEN] The second account is not on the page, the third account is set as default
+ Assert.IsTrue(FileAccountsTestPage.GoToKey(FirstAccountId, Enum::"File System Connector"::"Test File System Connector"), 'The first File account should be on the page');
+ Assert.IsFalse(GetDefaultFieldValueAsBoolean(FileAccountsTestPage.DefaultField.Value), 'The first account should not be marked as default');
+
+ Assert.IsFalse(FileAccountsTestPage.GoToKey(SecondAccount."Account Id", Enum::"File System Connector"::"Test File System Connector"), 'The second File account should not be on the page');
+
+ Assert.IsTrue(FileAccountsTestPage.GoToKey(ThirdAccountId, Enum::"File System Connector"::"Test File System Connector"), 'The third File account should be on the page');
+ Assert.IsTrue(GetDefaultFieldValueAsBoolean(FileAccountsTestPage.DefaultField.Value), 'The third account should be marked as default');
+ end;
+
+ [ModalPageHandler]
+ procedure AddAccountModalPageHandler(var AccountWizardTestPage: TestPage "File Account Wizard")
+ begin
+ end;
+
+ [ModalPageHandler]
+ procedure ChooseNewDefaultAccountCancelHandler(var AccountsPage: TestPage "File Accounts")
+ begin
+ AccountsPage.Cancel().Invoke();
+ end;
+
+ [ModalPageHandler]
+ procedure ChooseNewDefaultAccountHandler(var AccountsPage: TestPage "File Accounts")
+ begin
+ AccountsPage.GoToKey(AccountToSelect, Enum::"File System Connector"::"Test File System Connector");
+ AccountsPage.OK().Invoke();
+ end;
+
+ [ConfirmHandler]
+ procedure ConfirmYesHandler(Question: Text[1024]; var Reply: Boolean)
+ begin
+ Reply := true;
+ end;
+
+ [ConfirmHandler]
+ procedure ConfirmNoHandler(Question: Text[1024]; var Reply: Boolean)
+ begin
+ Reply := false;
+ end;
+
+ local procedure GetDefaultFieldValueAsBoolean(DefaultFieldValue: Text): Boolean
+ begin
+ exit(DefaultFieldValue = '✓');
+ end;
+}
diff --git a/src/System Application/Test/File System/src/FileScenarioPageTest.Codeunit.al b/src/System Application/Test/File System/src/FileScenarioPageTest.Codeunit.al
new file mode 100644
index 0000000000..4328a0b6d8
--- /dev/null
+++ b/src/System Application/Test/File System/src/FileScenarioPageTest.Codeunit.al
@@ -0,0 +1,206 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.Test.FileSystem;
+
+using System.TestLibraries.FileSystem;
+using System.FileSystem;
+using System.TestLibraries.Utilities;
+using System.TestLibraries.Security.AccessControl;
+
+codeunit 134751 "File Scenario Page Test"
+{
+ Subtype = Test;
+
+ var
+ FileConnectorMock: Codeunit "File Connector Mock";
+ FileScenarioMock: Codeunit "File Scenario Mock";
+ Assert: Codeunit "Library Assert";
+ PermissionsMock: Codeunit "Permissions Mock";
+ DisplayNameTxt: Label '%1', Locked = true;
+
+ [Test]
+ [Scope('OnPrem')]
+ [TransactionModel(TransactionModel::AutoRollback)]
+ procedure PageOpenNoData()
+ var
+ FileScenarioPage: TestPage "File Scenario Setup";
+ begin
+ // [Scenario] The "File Scenario Setup" shows no data when there are no file accounts
+ PermissionsMock.Set('File System Admin');
+
+ // [Given] No file account is registered.
+ FileConnectorMock.Initialize();
+
+ // [When] Opening the the page
+ FileScenarioPage.Trap();
+ FileScenarioPage.OpenView();
+
+ // [Then] There is no data on the page
+ Assert.IsFalse(FileScenarioPage.First(), 'There should be no data on the page');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ [TransactionModel(TransactionModel::AutoRollback)]
+ procedure PageOpenOneEntryTest()
+ var
+ FileAccount: Record "File Account";
+ FileScenarioPage: TestPage "File Scenario Setup";
+ begin
+ // [Scenario] The "File Scenario Setup" shows one entry when there is only one file account and no scenarios
+ PermissionsMock.Set('File System Admin');
+
+ // [Given] One file account is registered.
+ FileConnectorMock.Initialize();
+ FileConnectorMock.AddAccount(FileAccount);
+
+ // [When] Opening the the page
+ FileScenarioPage.Trap();
+ FileScenarioPage.OpenView();
+
+ // [Then] There is one entry on the page and it is not set as default
+ Assert.IsTrue(FileScenarioPage.First(), 'There should be an entry on the page');
+
+ // Properties are as expected
+ Assert.AreEqual(StrSubstNo(DisplayNameTxt, FileAccount.Name), FileScenarioPage.Name.Value, 'Wrong entry name');
+ Assert.IsFalse(GetDefaultFieldValueAsBoolean(FileScenarioPage.Default.Value), 'The account should not be marked as default');
+
+ // Actions visibility is as expected
+ Assert.IsTrue(FileScenarioPage.AddScenario.Visible(), 'The action "Add Scenarios" should be visible');
+ Assert.IsFalse(FileScenarioPage.ChangeAccount.Visible(), 'The action "Change Accounts" should not be visible');
+ Assert.IsFalse(FileScenarioPage.Unassign.Visible(), 'The action "Unassign" should not be visible');
+
+ Assert.IsFalse(FileScenarioPage.Next(), 'There should not be another entry on the page');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ procedure PageOpenOneDefaultEntryTest()
+ var
+ FileAccount: Record "File Account";
+ FileScenarioPage: TestPage "File Scenario Setup";
+ begin
+ // [Scenario] The "File Scenario Setup" shows one entry when there is only one file account and no scenarios
+ PermissionsMock.Set('File System Admin');
+
+ // [Given] One file account is registered and it's set as default.
+ FileConnectorMock.Initialize();
+ FileConnectorMock.AddAccount(FileAccount);
+
+ FileScenarioMock.DeleteAllMappings();
+ FileScenarioMock.AddMapping(Enum::"File Scenario"::Default, FileAccount."Account Id", FileAccount.Connector);
+
+ // [When] Opening the the page
+ FileScenarioPage.Trap();
+ FileScenarioPage.OpenView();
+
+ // [Then] There is one entry on the page and it is set as default
+ Assert.IsTrue(FileScenarioPage.First(), 'There should be an entry on the page');
+
+ // Properties are as expected
+ Assert.AreEqual(StrSubstNo(DisplayNameTxt, FileAccount.Name), FileScenarioPage.Name.Value, 'Wrong entry name');
+ Assert.IsTrue(GetDefaultFieldValueAsBoolean(FileScenarioPage.Default.Value), 'The account should be marked as default');
+
+ // Actions visibility is as expected
+ Assert.IsTrue(FileScenarioPage.AddScenario.Visible(), 'The action "Add Scenarios" should be visible');
+ Assert.IsFalse(FileScenarioPage.ChangeAccount.Visible(), 'The action "Change Accounts" should not be visible');
+ Assert.IsFalse(FileScenarioPage.Unassign.Visible(), 'The action "Unassign" should not be visible');
+
+ Assert.IsFalse(FileScenarioPage.Next(), 'There should not be another entry on the page');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ [TransactionModel(TransactionModel::AutoRollback)]
+ procedure PageOpenOneAcountsTwoScenariosTest()
+ var
+ FileAccount: Record "File Account";
+ FileScenarioPage: TestPage "File Scenario Setup";
+ begin
+ // [Scenario] Having one default account with a non-default scenario assigned displays properly on "File Scenario Setup"
+ PermissionsMock.Set('File System Admin');
+
+ // [Given] One file account is registered and it's set as default.
+ FileConnectorMock.Initialize();
+ FileConnectorMock.AddAccount(FileAccount);
+
+ FileScenarioMock.DeleteAllMappings();
+ FileScenarioMock.AddMapping(Enum::"File Scenario"::Default, FileAccount."Account Id", FileAccount.Connector);
+ FileScenarioMock.AddMapping(Enum::"File Scenario"::"Test File Scenario", FileAccount."Account Id", FileAccount.Connector);
+
+ // [When] Opening the the page
+ FileScenarioPage.Trap();
+ FileScenarioPage.OpenView();
+
+ // [Then] There is one entry on the page and it is set as default. There's another entry for the other assigned scenario
+ Assert.IsTrue(FileScenarioPage.First(), 'There should be data on the page');
+
+ // Properties are as expected
+ Assert.AreEqual(StrSubstNo(DisplayNameTxt, FileAccount.Name), FileScenarioPage.Name.Value, 'Wrong entry name');
+ Assert.IsTrue(GetDefaultFieldValueAsBoolean(FileScenarioPage.Default.Value), 'The account should be marked as default');
+
+ // Actions visibility is as expected
+ Assert.IsTrue(FileScenarioPage.AddScenario.Visible(), 'The action "Add Scenarios" should be visible');
+ Assert.IsFalse(FileScenarioPage.ChangeAccount.Visible(), 'The action "Change Accounts" should not be visible');
+ Assert.IsFalse(FileScenarioPage.Unassign.Visible(), 'The action "Unassign" should not be visible');
+
+ FileScenarioPage.Expand(true);
+ Assert.IsTrue(FileScenarioPage.Next(), 'There should be another entry on the page');
+
+ // Properties are as expected
+ Assert.AreEqual(Format(Enum::"File Scenario"::"Test File Scenario"), FileScenarioPage.Name.Value, 'Wrong entry name');
+ Assert.IsFalse(GetDefaultFieldValueAsBoolean(FileScenarioPage.Default.Value), 'The account should not be marked as default');
+
+ // Actions visibility is as expected
+ Assert.IsFalse(FileScenarioPage.AddScenario.Visible(), 'The action "Add Scenarios" should be visible');
+ Assert.IsTrue(FileScenarioPage.ChangeAccount.Visible(), 'The action "Change Accounts" should not be visible');
+ Assert.IsTrue(FileScenarioPage.Unassign.Visible(), 'The action "Unassign" should not be visible');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ [TransactionModel(TransactionModel::AutoRollback)]
+ procedure PageOpenTwoAcountsTwoScenariosTest()
+ var
+ FirstFileAccount, SecondFileAccount : Record "File Account";
+ FileScenarioPage: TestPage "File Scenario Setup";
+ begin
+ // [Scenario] The "File Scenario Setup" shows three entries when there are two accounts - one with the default scenario and one with a non-default scenario
+ PermissionsMock.Set('File System Admin');
+
+ // [Given] Two file accounts are registered. One is set as default.
+ FileConnectorMock.Initialize();
+ FileConnectorMock.AddAccount(FirstFileAccount);
+ FileConnectorMock.AddAccount(SecondFileAccount);
+
+ FileScenarioMock.DeleteAllMappings();
+ FileScenarioMock.AddMapping(Enum::"File Scenario"::Default, FirstFileAccount."Account Id", FirstFileAccount.Connector);
+ FileScenarioMock.AddMapping(Enum::"File Scenario"::"Test File Scenario", SecondFileAccount."Account Id", SecondFileAccount.Connector);
+
+ // [When] Opening the the page
+ FileScenarioPage.Trap();
+ FileScenarioPage.OpenView();
+
+ // [Then] There are three entries on the page. One is set as default
+ Assert.IsTrue(FileScenarioPage.GoToKey(-1, FirstFileAccount."Account Id", FirstFileAccount.Connector), 'There should be data on the page');
+ Assert.AreEqual(StrSubstNo(DisplayNameTxt, FirstFileAccount.Name), FileScenarioPage.Name.Value, 'Wrong first entry name');
+ Assert.IsTrue(GetDefaultFieldValueAsBoolean(FileScenarioPage.Default.Value), 'The account should be marked as default');
+
+ Assert.IsTrue(FileScenarioPage.GoToKey(-1, SecondFileAccount."Account Id", SecondFileAccount.Connector), 'There should be another entry on the page');
+ Assert.AreEqual(StrSubstNo(DisplayNameTxt, SecondFileAccount.Name), FileScenarioPage.Name.Value, 'Wrong second entry name');
+ Assert.IsFalse(GetDefaultFieldValueAsBoolean(FileScenarioPage.Default.Value), 'The account should not be marked as default');
+
+ FileScenarioPage.Expand(true);
+ Assert.IsTrue(FileScenarioPage.Next(), 'There should be a third entry on the page');
+ Assert.AreEqual(Format(Enum::"File Scenario"::"Test File Scenario"), FileScenarioPage.Name.Value, 'Wrong third entry name');
+ Assert.IsFalse(GetDefaultFieldValueAsBoolean(FileScenarioPage.Default.Value), 'The account should not be marked as default');
+ end;
+
+ local procedure GetDefaultFieldValueAsBoolean(DefaultFieldValue: Text): Boolean
+ begin
+ exit(DefaultFieldValue = '✓');
+ end;
+}
\ No newline at end of file
diff --git a/src/System Application/Test/File System/src/FileScenarioTest.Codeunit.al b/src/System Application/Test/File System/src/FileScenarioTest.Codeunit.al
new file mode 100644
index 0000000000..f4cece8d13
--- /dev/null
+++ b/src/System Application/Test/File System/src/FileScenarioTest.Codeunit.al
@@ -0,0 +1,286 @@
+// ------------------------------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// ------------------------------------------------------------------------------------------------
+
+namespace System.Test.FileSystem;
+
+using System.FileSystem;
+using System.TestLibraries.FileSystem;
+using System.TestLibraries.Utilities;
+using System.TestLibraries.Security.AccessControl;
+
+codeunit 134752 "File Scenario Test"
+{
+ Subtype = Test;
+
+ var
+ Any: Codeunit Any;
+ FileConnectorMock: Codeunit "File Connector Mock";
+ FileScenario: Codeunit "File Scenario";
+ FileScenarioMock: Codeunit "File Scenario Mock";
+ Assert: Codeunit "Library Assert";
+ PermissionsMock: Codeunit "Permissions Mock";
+
+ [Test]
+ [Scope('OnPrem')]
+ procedure GetFileAccountScenarioNotExistsTest()
+ var
+ FileAccount: Record "File Account";
+ begin
+ // [Scenario] When the File scenario isn't mapped an File account, GetFileAccount returns false
+ PermissionsMock.Set('File System Admin');
+
+ // [Given] No mappings between Files and scenarios
+ Initialize();
+
+ // [When] calling GetFileAccount
+ // [Then] false is returned
+ Assert.IsFalse(FileScenario.GetFileAccount(Enum::"File Scenario"::"Test File Scenario", FileAccount), 'There should not be any account');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ procedure GetFileAccountNotExistsTest()
+ var
+ FileAccount: Record "File Account";
+ NonExistentAccountId: Guid;
+ begin
+ // [Scenario] When the File scenario is mapped non-existing File account, GetFileAccount returns false
+ PermissionsMock.Set('File System Admin');
+
+ // [Given] An File scenario pointing to a non-existing File account
+ Initialize();
+ NonExistentAccountId := Any.GuidValue();
+ FileScenarioMock.AddMapping(Enum::"File Scenario"::"Test File Scenario", NonExistentAccountId, Enum::"File System Connector"::"Test File System Connector");
+
+ // [When] calling GetFileAccount
+ // [Then] false is returned
+ Assert.IsFalse(FileScenario.GetFileAccount(Enum::"File Scenario"::"Test File Scenario", FileAccount), 'There should not be any account mapped to the scenario');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ procedure GetFileAccountDefaultNotExistsTest()
+ var
+ FileAccount: Record "File Account";
+ NonExistentAccountId: Guid;
+ begin
+ // [Scenario] When the default File scenario is mapped to a non-existing File account, GetFileAccount returns false
+ PermissionsMock.Set('File System Admin');
+
+ // [Given] An File scenario isn't mapped to a account and the default scenario is mapped to a non-existing account
+ Initialize();
+ NonExistentAccountId := Any.GuidValue();
+ FileScenarioMock.AddMapping(Enum::"File Scenario"::Default, NonExistentAccountId, Enum::"File System Connector"::"Test File System Connector");
+
+ // [When] calling GetFileAccount
+ // [Then] false is returned
+ Assert.IsFalse(FileScenario.GetFileAccount(Enum::"File Scenario"::"Test File Scenario", FileAccount), 'There should not be any account mapped to the scenario');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ procedure GetFileAccountDefaultExistsTest()
+ var
+ FileAccount: Record "File Account";
+ AccountId: Guid;
+ begin
+ // [Scenario] When the default File scenario is mapped to an existing File account, GetFileAccount returns that account
+ PermissionsMock.Set('File System Admin');
+
+ // [Given] An File scenario isn't mapped to an account and the default scenario is mapped to an existing account
+ Initialize();
+ FileConnectorMock.AddAccount(AccountId);
+ FileScenarioMock.AddMapping(Enum::"File Scenario"::Default, AccountId, Enum::"File System Connector"::"Test File System Connector");
+
+ // [When] calling GetFileAccount
+ // [Then] true is returned and the File account is as expected
+ Assert.IsTrue(FileScenario.GetFileAccount(Enum::"File Scenario"::"Test File Scenario", FileAccount), 'There should be an File account');
+ Assert.AreEqual(AccountId, FileAccount."Account Id", 'Wrong account ID');
+ Assert.AreEqual(Enum::"File System Connector"::"Test File System Connector", FileAccount.Connector, 'Wrong connector');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ procedure GetFileAccountExistsTest()
+ var
+ FileAccount: Record "File Account";
+ AccountId: Guid;
+ begin
+ // [Scenario] When the File scenario is mapped to an existing File account, GetFileAccount returns that account
+ PermissionsMock.Set('File System Admin');
+
+ // [Given] An File scenario is mapped to an account
+ Initialize();
+ FileConnectorMock.AddAccount(AccountId);
+ FileScenarioMock.AddMapping(Enum::"File Scenario"::"Test File Scenario", AccountId, Enum::"File System Connector"::"Test File System Connector");
+
+ // [When] calling GetFileAccount
+ // [Then] true is returned and the File account is as expected
+ Assert.IsTrue(FileScenario.GetFileAccount(Enum::"File Scenario"::"Test File Scenario", FileAccount), 'There should be an File account');
+ Assert.AreEqual(AccountId, FileAccount."Account Id", 'Wrong account ID');
+ Assert.AreEqual(Enum::"File System Connector"::"Test File System Connector", FileAccount.Connector, 'Wrong connector');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ procedure GetFileAccountDefaultDifferentTest()
+ var
+ FileAccount: Record "File Account";
+ AccountId: Guid;
+ DefaultAccountId: Guid;
+ begin
+ // [Scenario] When the File scenario and the default scenario are mapped to different File accounts, GetFileAccount returns the correct account
+ PermissionsMock.Set('File System Admin');
+
+ // [Given] An File scenario is mapped to an account, the default scenario is mapped to another account
+ Initialize();
+ FileConnectorMock.AddAccount(AccountId);
+ FileConnectorMock.AddAccount(DefaultAccountId);
+ FileScenarioMock.AddMapping(Enum::"File Scenario"::"Test File Scenario", AccountId, Enum::"File System Connector"::"Test File System Connector");
+ FileScenarioMock.AddMapping(Enum::"File Scenario"::Default, DefaultAccountId, Enum::"File System Connector"::"Test File System Connector");
+
+ // [When] calling GetFileAccount
+ // [Then] true is returned and the File accounts are as expected
+ Assert.IsTrue(FileScenario.GetFileAccount(Enum::"File Scenario"::"Test File Scenario", FileAccount), 'There should be an File account');
+ Assert.AreEqual(AccountId, FileAccount."Account Id", 'Wrong account ID');
+ Assert.AreEqual(Enum::"File System Connector"::"Test File System Connector", FileAccount.Connector, 'Wrong connector');
+
+ Assert.IsTrue(FileScenario.GetFileAccount(Enum::"File Scenario"::Default, FileAccount), 'There should be an File account');
+ Assert.AreEqual(DefaultAccountId, FileAccount."Account Id", 'Wrong account ID');
+ Assert.AreEqual(Enum::"File System Connector"::"Test File System Connector", FileAccount.Connector, 'Wrong connector');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ procedure GetFileAccountDefaultDifferentNotExistTest()
+ var
+ FileAccount: Record "File Account";
+ DefaultAccountId: Guid;
+ NonExistingAccountId: Guid;
+ begin
+ // [Scenario] When the File scenario is mapped to a non-existing account and the default scenario is mapped to an existing accounts, GetFileAccount returns the correct account
+ PermissionsMock.Set('File System Admin');
+
+ // [Given] An File scenario is mapped to a non-existing account, the default scenario is mapped to an existing account
+ Initialize();
+ FileConnectorMock.AddAccount(DefaultAccountId);
+ NonExistingAccountId := Any.GuidValue();
+ FileScenarioMock.AddMapping(Enum::"File Scenario"::"Test File Scenario", NonExistingAccountId, Enum::"File System Connector"::"Test File System Connector");
+ FileScenarioMock.AddMapping(Enum::"File Scenario"::Default, DefaultAccountId, Enum::"File System Connector"::"Test File System Connector");
+
+ // [When] calling GetFileAccount
+ // [Then] true is returned and the File accounts are as expected
+ Assert.IsTrue(FileScenario.GetFileAccount(Enum::"File Scenario"::"Test File Scenario", FileAccount), 'There should be an File account');
+ Assert.AreEqual(DefaultAccountId, FileAccount."Account Id", 'Wrong account ID');
+ Assert.AreEqual(Enum::"File System Connector"::"Test File System Connector", FileAccount.Connector, 'Wrong connector');
+
+ Assert.IsTrue(FileScenario.GetFileAccount(Enum::"File Scenario"::Default, FileAccount), 'There should be an File account for the default scenario');
+ Assert.AreEqual(DefaultAccountId, FileAccount."Account Id", 'Wrong default account ID');
+ Assert.AreEqual(Enum::"File System Connector"::"Test File System Connector", FileAccount.Connector, 'Wrong default account connector');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ procedure GetFileAccountDifferentDefaultNotExistTest()
+ var
+ FileAccount: Record "File Account";
+ AccountId: Guid;
+ DefaultAccountId: Guid;
+ begin
+ // [Scenario] When the File scenario is mapped to an existing account and the default scenario is mapped to a non-existing accounts, GetFileAccount returns the correct account
+ PermissionsMock.Set('File System Admin');
+
+ // [Given] An File scenario is mapped to an existing account, the default scenario is mapped to a non-existing account
+ Initialize();
+ FileConnectorMock.AddAccount(AccountId);
+ DefaultAccountId := Any.GuidValue();
+ FileScenarioMock.AddMapping(Enum::"File Scenario"::"Test File Scenario", AccountId, Enum::"File System Connector"::"Test File System Connector");
+ FileScenarioMock.AddMapping(Enum::"File Scenario"::Default, DefaultAccountId, Enum::"File System Connector"::"Test File System Connector");
+
+ // [When] calling GetFileAccount
+ // [Then] true is returned and the File account is as expected
+ Assert.IsTrue(FileScenario.GetFileAccount(Enum::"File Scenario"::"Test File Scenario", FileAccount), 'There should be an File account');
+ Assert.AreEqual(AccountId, FileAccount."Account Id", 'Wrong account ID');
+ Assert.AreEqual(Enum::"File System Connector"::"Test File System Connector", FileAccount.Connector, 'Wrong connector');
+
+ // [Then] there's no account for the default File scenario
+ Assert.IsFalse(FileScenario.GetFileAccount(Enum::"File Scenario"::Default, FileAccount), 'There should not be an File account for the default scenario');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ procedure SetFileAccountTest()
+ var
+ FileAccount: Record "File Account";
+ AnotherAccount: Record "File Account";
+ FileSystemTestLib: Codeunit "File System Test Lib.";
+ FileSystemConnector: Interface "File System Connector";
+ AccountId: Guid;
+ Scenario: Enum "File Scenario";
+ begin
+ // [Scenario] When SetAccount is called, the entry in the database is as expected
+ PermissionsMock.Set('File System Admin');
+
+ // [Given] A random File account
+ Initialize();
+ FileAccount."Account Id" := Any.GuidValue();
+ FileAccount.Connector := Enum::"File System Connector"::"Test File System Connector";
+ Scenario := Scenario::Default;
+
+ // [When] Setting the File account for the scenario
+ FileScenario.SetFileAccount(Scenario, FileAccount);
+
+ // [Then] The scenario exists and is as expected
+ Assert.IsTrue(FileSystemTestLib.GetFileScenarioAccountIdAndFileConnector(Scenario, AccountId, FileSystemConnector), 'The File scenario should exist');
+ Assert.AreEqual(AccountId, FileAccount."Account Id", 'Wrong account ID');
+ Assert.AreEqual(Enum::"File System Connector"::"Test File System Connector", FileAccount.Connector, 'Wrong connector');
+
+ AnotherAccount."Account Id" := Any.GuidValue();
+ AnotherAccount.Connector := Enum::"File System Connector"::"Test File System Connector";
+
+ // [When] Setting overwriting the File account for the scenario
+ FileScenario.SetFileAccount(Scenario, AnotherAccount);
+
+ // [Then] The scenario still exists and is as expected
+ Assert.IsTrue(FileSystemTestLib.GetFileScenarioAccountIdAndFileConnector(Scenario, AccountId, FileSystemConnector), 'The File scenario should exist');
+ Assert.AreEqual(AccountId, AnotherAccount."Account Id", 'Wrong account ID');
+ Assert.AreEqual(Enum::"File System Connector"::"Test File System Connector", AnotherAccount.Connector, 'Wrong connector');
+ end;
+
+ [Test]
+ [Scope('OnPrem')]
+ procedure UnassignScenarioTest()
+ var
+ DefaultAccount: Record "File Account";
+ FileAccount: Record "File Account";
+ ResultAccount: Record "File Account";
+ begin
+ // [Scenario] When unassigning a scenario then it falls back to the default account.
+ PermissionsMock.Set('File System Admin');
+
+ // [Given] Two accounts, one default and one not
+ Initialize();
+ FileConnectorMock.AddAccount(FileAccount);
+ FileConnectorMock.AddAccount(DefaultAccount);
+ FileScenario.SetDefaultFileAccount(DefaultAccount);
+ FileScenario.SetFileAccount(Enum::"File Scenario"::"Test File Scenario", FileAccount);
+
+ // mid-test verification
+ FileScenario.GetFileAccount(Enum::"File Scenario"::"Test File Scenario", ResultAccount);
+ Assert.AreEqual(FileAccount."Account Id", ResultAccount."Account Id", 'Wrong account');
+
+ // [When] Unassign the File scenario
+ FileScenario.UnassignScenario(Enum::"File Scenario"::"Test File Scenario");
+
+ // [Then] The default account is returned for that account
+ FileScenario.GetFileAccount(Enum::"File Scenario"::"Test File Scenario", ResultAccount);
+ Assert.AreEqual(DefaultAccount."Account Id", ResultAccount."Account Id", 'The default account should have been returned');
+ end;
+
+ local procedure Initialize()
+ begin
+ FileScenarioMock.DeleteAllMappings();
+ end;
+}
\ No newline at end of file