Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

55 output enum int values instead ofas well as strings #69

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion businessCentral/app/permissions/Execute.PermissionSet.al
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ permissionset 82561 "ADLSE - Execute"
tabledata "ADLSE Deleted Record" = R,
tabledata "ADLSE Current Session" = RIMD,
tabledata "ADLSE Table Last Timestamp" = RIMD,
tabledata "ADLSE Run" = RIMD;
tabledata "ADLSE Run" = RIMD,
tabledata "ADLSE Enum Translation" = RIMD,
tabledata "ADLSE Enum Translation Lang" = RIMD;
}
109 changes: 109 additions & 0 deletions businessCentral/app/src/EnumTranslation.Table.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
table 82567 "ADLSE Enum Translation"
{
DataClassification = ToBeClassified;
Caption = 'ADLSE Enum Translation';
Access = Internal;

fields
{
field(1; "Table Id"; Integer)
{
DataClassification = SystemMetadata;
Caption = 'Table Id';
}
field(2; "Compliant Table Name"; Text[40])
{
DataClassification = SystemMetadata;
Caption = 'Compliant Table Name';
}
field(3; "Field Id"; Integer)
{
DataClassification = SystemMetadata;
Caption = 'Field Id';
}
field(4; "Compliant Field Name"; Text[40])
{
DataClassification = SystemMetadata;
Caption = 'Compliant Object Name';
}
}

keys
{
key(Key1; "Table Id", "Field Id")
{
Clustered = true;
}
}

local procedure InsertEnum(TableId: Integer; FieldNo: Integer; FieldName: Text[30])
var
ADLSEUtil: Codeunit "ADLSE Util";
begin
Rec.Init();
Rec."Table Id" := TableId;
Rec."Compliant Table Name" := CopyStr(ADLSEUtil.GetDataLakeCompliantTableName(TableId), 1, MaxStrLen((Rec."Compliant Table Name")));
Rec."Field Id" := FieldNo;
Rec."Compliant Field Name" := CopyStr(ADLSEUtil.GetDataLakeCompliantFieldName(FieldName, FieldNo), 1, MaxStrLen((Rec."Compliant Field Name")));
Rec.Insert();
end;

procedure RefreshOptions()
var
ADLSETable: Record "ADLSE Table";
ADLSEEnumTranslation: Record "ADLSE Enum Translation";
ADLSEEnumTranslationLang: Record "ADLSE Enum Translation Lang";
RecordField: Record Field;
ADLSERecordRef: RecordRef;
begin
ADLSEEnumTranslation.DeleteAll();
ADLSEEnumTranslationLang.DeleteAll();

if ADLSETable.FindSet() then
repeat
RecordField.SetRange(TableNo, ADLSETable."Table ID");
RecordField.SetRange("Type", RecordField."Type"::Option);
RecordField.SetFilter(ObsoleteState, '<>%1', RecordField.ObsoleteState::Removed);
ADLSERecordRef.Open(ADLSETable."Table ID");
if RecordField.FindSet() then
repeat
InsertEnums(ADLSERecordRef, RecordField);
until RecordField.Next() = 0;
ADLSERecordRef.Close();
until ADLSETable.Next() = 0;

if not ADLSETable.Get(Rec.RecordId.TableNo) then begin
ADLSETable.Add(Rec.RecordId.TableNo);
ADLSETable.AddAllFields();
end;
if not ADLSETable.Get(ADLSEEnumTranslationLang.RecordId.TableNo) then begin
ADLSETable.Add(ADLSEEnumTranslationLang.RecordId.TableNo);
ADLSETable.AddAllFields();
end;
end;

local procedure InsertEnums(ADLSERecordRef: RecordRef; FieldRec: Record Field)
var
ADLSESetup: Record "ADLSE Setup";
ADLSEEnumTranslationLang: Record "ADLSE Enum Translation Lang";
TranslationHelper: Codeunit "Translation Helper";
FieldRef: FieldRef;
i: Integer;
x: Integer;
Translations: List of [Text];
begin
ADLSESetup.GetSingleton();
FieldRef := ADLSERecordRef.Field(FieldRec."No.");
InsertEnum(FieldRec.TableNo, FieldRec."No.", FieldRec.FieldName);
for i := 1 to FieldRef.EnumValueCount() do begin
//Insert language captions
Translations := ADLSESetup.Translations.Split(';');
Translations.Remove('');
for x := 1 to Translations.Count() do begin
TranslationHelper.SetGlobalLanguageByCode(Translations.Get(x));
ADLSEEnumTranslationLang.InsertEnumLanguage(Translations.Get(x), FieldRec.TableNo, FieldRec."No.", FieldRec.FieldName, FieldRef.GetEnumValueOrdinal(i), FieldRef.GetEnumValueCaption(i));
end;
end;
TranslationHelper.RestoreGlobalLanguage();
end;
}
68 changes: 68 additions & 0 deletions businessCentral/app/src/EnumTranslationLang.Table.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
table 82568 "ADLSE Enum Translation Lang"
{
DataClassification = ToBeClassified;
Caption = 'ADLSE Enum Translation Language';
Access = Internal;

fields
{
field(1; "Language Code"; Code[10])
{
DataClassification = SystemMetadata;
Caption = 'Language Code';
}
field(2; "Table Id"; Integer)
{
DataClassification = SystemMetadata;
Caption = 'Table Id';
}
field(3; "Compliant Table Name"; Text[40])
{
DataClassification = SystemMetadata;
Caption = 'Compliant Table Name';
}
field(4; "Field Id"; Integer)
{
DataClassification = SystemMetadata;
Caption = 'Field Id';
}
field(5; "Compliant Field Name"; Text[40])
{
DataClassification = SystemMetadata;
Caption = 'Compliant Object Name';
}
field(6; "Enum Value Id"; Integer)
{
DataClassification = SystemMetadata;
Caption = 'Enum Index';
}
field(7; "Enum Value Caption"; Text[100])
{
DataClassification = SystemMetadata;
Caption = 'Enum Caption';
}
}

keys
{
key(Key1; "Language Code", "Table Id", "Field Id", "Enum Value Id")
{
Clustered = true;
}
}

procedure InsertEnumLanguage(LanguageCode: Code[10]; TableId: Integer; FieldNo: Integer; FieldName: Text[30]; EnumValueOrdinal: Integer; EnumValueName: Text)
var
ADLSEUtil: Codeunit "ADLSE Util";
begin
Rec.Init();
Rec."Language Code" := LanguageCode;
Rec."Table Id" := TableId;
Rec."Compliant Table Name" := CopyStr(ADLSEUtil.GetDataLakeCompliantTableName(TableId), 1, MaxStrLen((Rec."Compliant Table Name")));
Rec."Field Id" := FieldNo;
Rec."Compliant Field Name" := CopyStr(ADLSEUtil.GetDataLakeCompliantFieldName(FieldName, FieldNo), 1, MaxStrLen((Rec."Compliant Field Name")));
Rec."Enum Value Id" := EnumValueOrdinal;
Rec."Enum Value Caption" := CopyStr(EnumValueName, 1, MaxStrLen(Rec."Enum Value Caption"));
Rec.Insert();
end;
}
77 changes: 77 additions & 0 deletions businessCentral/app/src/EnumTranslations.Page.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//A list page that is build on table Enum Translation
page 82569 "ADLSE Enum Translations"
{
PageType = List;
ApplicationArea = All;
UsageCategory = Lists;
SourceTable = "ADLSE Enum Translation";


layout
{
area(Content)
{
repeater(GroupName)
{
field(CompliantTableName; Rec."Compliant Table Name")
{
Editable = false;
ToolTip = 'The name of the table that is compliant with Data Lake standards.';
}
field(CompliantFieldName; Rec."Compliant Field Name")
{
Editable = false;
ToolTip = 'The name of the field that is compliant with Data Lake standards.';
}
}
}
}

actions
{
area(Processing)
{
action(RefreshOptions)
{
ApplicationArea = All;
Caption = 'Refresh Options';
ToolTip = 'Refresh the options of the enum fields.';
Image = Refresh;

trigger OnAction();
begin
Rec.RefreshOptions();
end;
}
}
area(Navigation)
{
action(Translations)
{
ApplicationArea = All;
Caption = 'Translations';
ToolTip = 'View the translations of the enum fields.';
Image = Language;

trigger OnAction();
var
ADLSEEnumTranslationLang: Record "ADLSE Enum Translation Lang";
ADLSEEnumTranslationsLang: Page "ADLSE Enum Translations Lang";
begin
ADLSEEnumTranslationLang.SetRange("Table Id", Rec."Table Id");
ADLSEEnumTranslationLang.SetRange("Field Id", Rec."Field Id");
ADLSEEnumTranslationsLang.SetSelectionFilter(ADLSEEnumTranslationLang);
ADLSEEnumTranslationsLang.RunModal();
end;
}
}
area(Promoted)
{
group(Category_Process)
{
Caption = 'Process';
actionref(RefreshOptions_Promoted; RefreshOptions) { }
}
}
}
}
39 changes: 39 additions & 0 deletions businessCentral/app/src/EnumTranslationsLang.Page.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//A list page that is build on table Enum Translation
page 82570 "ADLSE Enum Translations Lang"
{
PageType = List;
ApplicationArea = All;
UsageCategory = Lists;
SourceTable = "ADLSE Enum Translation Lang";


layout
{
area(Content)
{
repeater(GroupName)
{
field(LanguageCode; Rec."Language Code")
{
Editable = false;
ToolTip = 'The language code.';
}
field(CompliantTableName; Rec."Compliant Table Name")
{
Editable = false;
ToolTip = 'The name of the table that is compliant with Data Lake standards.';
}
field(CompliantFieldName; Rec."Compliant Field Name")
{
Editable = false;
ToolTip = 'The name of the field that is compliant with Data Lake standards.';
}
field(EnumValueCaption; Rec."Enum Value Caption")
{
Editable = false;
ToolTip = 'The caption of the enum value.';
}
}
}
}
}
Loading
Loading