From cf43091239010019f179b43f32b242f4df36124f Mon Sep 17 00:00:00 2001 From: Bert Verbeek Date: Thu, 18 Apr 2024 09:32:10 +0200 Subject: [PATCH] Added Business Event for Refresh Option and an API for it. --- businessCentral/app/src/EnumTranslation.Table.al | 4 ++++ .../app/src/ExternalEvents.Codeunit.al | 16 ++++++++++++++++ businessCentral/app/src/SetupAPIv11.Page.al | 9 +++++++++ 3 files changed, 29 insertions(+) diff --git a/businessCentral/app/src/EnumTranslation.Table.al b/businessCentral/app/src/EnumTranslation.Table.al index 829d4a0..a461c09 100644 --- a/businessCentral/app/src/EnumTranslation.Table.al +++ b/businessCentral/app/src/EnumTranslation.Table.al @@ -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(); @@ -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) diff --git a/businessCentral/app/src/ExternalEvents.Codeunit.al b/businessCentral/app/src/ExternalEvents.Codeunit.al index 2ebd9ca..324c687 100644 --- a/businessCentral/app/src/ExternalEvents.Codeunit.al +++ b/businessCentral/app/src/ExternalEvents.Codeunit.al @@ -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"; @@ -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 diff --git a/businessCentral/app/src/SetupAPIv11.Page.al b/businessCentral/app/src/SetupAPIv11.Page.al index 23938f3..067a540 100644 --- a/businessCentral/app/src/SetupAPIv11.Page.al +++ b/businessCentral/app/src/SetupAPIv11.Page.al @@ -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