Skip to content

Commit

Permalink
Added Business Event for Refresh Option and an API for it. (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertverbeek4PS committed Apr 18, 2024
2 parents 3a48f51 + cf43091 commit 9210ba1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions businessCentral/app/src/EnumTranslation.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ table 82567 "ADLSE Enum Translation"
ADLSETable: Record "ADLSE Table";
ADLSEEnumTranslation: Record "ADLSE Enum Translation";
ADLSEEnumTranslationLang: Record "ADLSE Enum Translation Lang";
ADLSESetupRec: Record "ADLSE Setup";
RecordField: Record Field;
ADLSEExternalEvents: Codeunit "ADLSE External Events";
ADLSERecordRef: RecordRef;
begin
ADLSEEnumTranslation.DeleteAll();
Expand All @@ -80,6 +82,8 @@ table 82567 "ADLSE Enum Translation"
ADLSETable.Add(ADLSEEnumTranslationLang.RecordId.TableNo);
ADLSETable.AddAllFields();
end;

ADLSEExternalEvents.OnRefreshOptions(ADLSESetupRec);
end;

local procedure InsertEnums(ADLSERecordRef: RecordRef; FieldRec: Record Field)
Expand Down
16 changes: 16 additions & 0 deletions businessCentral/app/src/ExternalEvents.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ codeunit 82574 "ADLSE External Events"
MyBusinessOnExportFinished(ADLSESetup.SystemId, ADLSESetup."Storage Type", Url, WebClientUrl);
end;

internal procedure OnRefreshOptions(ADLSESetup: Record "ADLSE Setup")
var
Url: Text[250];
WebClientUrl: Text[250];
ADLSEFieldApiUrlTok: Label 'bc2adlsTeamMicrosoft/bc2adls/v1.0/companies(%1)/adlseSetup(%2)', Locked = true;
begin
Url := ADLSEExternalEventsHelper.CreateLink(ADLSEFieldApiUrlTok, ADLSESetup.SystemId);
WebClientUrl := CopyStr(GetUrl(ClientType::Web, CompanyName(), ObjectType::Page, Page::"ADLSE Setup", ADLSESetup), 1, MaxStrLen(WebClientUrl));
MyBusinessOnRefreshOptions(ADLSESetup.SystemId, ADLSESetup."Storage Type", Url, WebClientUrl);
end;

local procedure GetSetup()
var
ADLSESetup: Record "ADLSE Setup";
Expand Down Expand Up @@ -186,6 +197,11 @@ codeunit 82574 "ADLSE External Events"
begin
end;

[ExternalBusinessEvent('OnRefreshOptions', 'Refresh Options', 'When the options are refreshed', EventCategory::ADLSE)]
local procedure MyBusinessOnRefreshOptions(SystemId: Guid; "Storage Type": Enum "ADLSE Storage Type"; Url: Text[250]; WebClientUrl: Text[250])
begin
end;

[EventSubscriber(ObjectType::Table, Database::"ADLSE Table", OnAfterResetSelected, '', true, true)]
local procedure OnAfterResetSelected(ADLSETable: Record "ADLSE Table");
begin
Expand Down
9 changes: 9 additions & 0 deletions businessCentral/app/src/SetupAPIv11.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ page 82568 "ADLSE Setup API v11"
SetActionResponse(ActionContext, Rec."SystemId");
end;

[ServiceEnabled]
procedure RefreshOptions(var ActionContext: WebServiceActionContext)
var
ADLSEEnumTranslation: Record "ADLSE Enum Translation";
begin
ADLSEEnumTranslation.RefreshOptions();
SetActionResponse(ActionContext, Rec."SystemId");
end;

local procedure SetActionResponse(var ActionContext: WebServiceActionContext; AdlsId: Guid)
var
begin
Expand Down

0 comments on commit 9210ba1

Please sign in to comment.