Skip to content

Commit

Permalink
Add validation for Workspace and Lakehouse fields in Setup.Table.al (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertverbeek4PS committed May 23, 2024
1 parent f20ab42 commit 1c7ff3b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
8 changes: 6 additions & 2 deletions businessCentral/app/src/Communication.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ codeunit 82562 "ADLSE Communication"
EntitySchemaChangedErr: Label 'The schema of the table %1 has changed. %2', Comment = '%1 = Entity name, %2 = NotAllowedOnSimultaneousExportTxt';
CdmSchemaChangedErr: Label 'There may have been a change in the tables to export. %1', Comment = '%1 = NotAllowedOnSimultaneousExportTxt';
MSFabricUrlTxt: Label 'https://onelake.dfs.fabric.microsoft.com/%1/%2.Lakehouse/Files', Locked = true, Comment = '%1: Workspace name, %2: Lakehouse Name';
MSFabricUrlGuidTxt: Label 'https://onelake.dfs.fabric.microsoft.com/%1/%2/Files', Locked = true, Comment = '%1: Workspace name, %2: Lakehouse Name';
ResetTableExportTxt: Label '/reset/%1.txt', Locked = true, comment = '%1 = Table name';

procedure SetupBlobStorage()
Expand All @@ -47,6 +48,7 @@ codeunit 82562 "ADLSE Communication"
local procedure GetBaseUrl(): Text
var
ADLSESetup: Record "ADLSE Setup";
ValidGuid: Guid;
begin
ADLSESetup.GetSingleton();
case ADLSESetup.GetStorageType() of
Expand All @@ -58,8 +60,10 @@ codeunit 82562 "ADLSE Communication"
exit(StrSubstNo(ContainerUrlTxt, ADLSESetup."Account Name", DefaultContainerName));
end;
ADLSESetup."Storage Type"::"Microsoft Fabric":
exit(StrSubstNo(MSFabricUrlTxt, ADLSESetup.Workspace, ADLSESetup.Lakehouse));

if not Evaluate(ValidGuid, ADLSESetup.Lakehouse) then
exit(StrSubstNo(MSFabricUrlTxt, ADLSESetup.Workspace, ADLSESetup.Lakehouse))
else
exit(StrSubstNo(MSFabricUrlGuidTxt, ADLSESetup.Workspace, ADLSESetup.Lakehouse));
end;
end;

Expand Down
26 changes: 24 additions & 2 deletions businessCentral/app/src/Setup.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,30 @@ table 82560 "ADLSE Setup"
field(30; Workspace; Text[100])
{
Caption = 'Workspace';
trigger OnValidate()
var
ValidGuid: Guid;
begin
if not Evaluate(ValidGuid, Rec.Workspace) then
if (StrLen(Rec.Workspace) < 3) or (StrLen(Rec.Workspace) > 24)
or TextCharactersOtherThan(Rec.Workspace, 'abcdefghijklmnopqrstuvwxyz1234567890_')
then
Error(WorkspaceIncorrectFormatErr);
end;
}
field(31; Lakehouse; Text[100])
{
Caption = 'Lakehouse';
trigger OnValidate()
var
ValidGuid: Guid;
begin
if not Evaluate(ValidGuid, Rec.Lakehouse) then
if (StrLen(Rec.Lakehouse) < 3) or (StrLen(Rec.Lakehouse) > 24)
or TextCharactersOtherThan(Rec.Lakehouse, 'abcdefghijklmnopqrstuvwxyz1234567890_')
then
Error(LakehouseIncorrectFormatErr);
end;
}
field(35; "Schema Exported On"; DateTime)
{
Expand Down Expand Up @@ -172,8 +192,10 @@ table 82560 "ADLSE Setup"

var
MaxReqErrorInfo: ErrorInfo;
ContainerNameIncorrectFormatErr: Label 'The container name is in an incorrect format.';
AccountNameIncorrectFormatErr: Label 'The account name is in an incorrect format.';
ContainerNameIncorrectFormatErr: Label 'The container name is in an incorrect format. Please only use abcdefghijklmnopqrstuvwxyz1234567890_';
AccountNameIncorrectFormatErr: Label 'The account name is in an incorrect format. Please only use abcdefghijklmnopqrstuvwxyz1234567890';
WorkspaceIncorrectFormatErr: Label 'The workspace is in an incorrect format. Please only use abcdefghijklmnopqrstuvwxyz1234567890_ or a valid GUID';
LakehouseIncorrectFormatErr: Label 'The lakehouse is in an incorrect format. Please only use abcdefghijklmnopqrstuvwxyz1234567890_ or a valid GUID';
RecordDoesNotExistErr: Label 'No record on this table exists.';
PrimaryKeyValueLbl: Label '0', Locked = true;
NoSchemaExportedErr: Label 'Schema already exported. Please perform the action "clear schema export date" before changing the schema.';
Expand Down

0 comments on commit 1c7ff3b

Please sign in to comment.