microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
785 stars 620 forks source link

[Event Request] Remove DotNet parameters from events #15140

Open ajkauffmann opened 3 years ago

ajkauffmann commented 3 years ago

Can you please remove the DotNet variables from the events in codeunit 8614 "Config. XML Exchange"

Some events in this codeunit pass parameters as DotNet objects. So they can't be used in a cloud extension. Internal work item: AB#416596

pri-kise commented 3 years ago

Normally you can only add the need parameters to a event subscriber. Without the Dotnet parameters a event subscriber should be possible. The following snippet does not create any error in my dummy project.

[IntegrationEvent(false, false)]
local procedure OnFillPackageMetadataFromXMLOnAfterGetPackageTableValueFromXML(ConfigPackageTable: Record "Config. Package Table"; var TableNode: DotNet XmlNode)
begin
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Config. XML Exchange", 'OnFillPackageMetadataFromXMLOnAfterGetPackageTableValueFromXML', '', false, false)]
local procedure OnFillPackageMetadataFromXMLOnAfterGetPackageTableValueFromXML(ConfigPackageTable: Record "Config. Package Table")
begin

end;
}

Wouldn't it be better if the Codeunit is refactored to the new XMl Types with new events....

ajkauffmann commented 3 years ago

Sure, I know that you can leave the parameters you don't need. But in this case, I need the Xml parameter.

Obviously, the best way to get rid of the DotNet parameters is to refactor the codeunit. I guess Microsoft is smart enough to recognize that. 😊 But after all, I don't really care what variable types are used internally, as long as I can use the events. 😊

Oleg-Romashkov commented 2 years ago

Hi,

Do you have any suggestions which parameters should be used instead of DotNet to fit you needs (same object as text, etc)? It would be nice to have some scenarios/examples of using those events to simplify the refactoring.

ajkauffmann commented 2 years ago

It is used to create extra XML elements and add them to the TableNode parameter. In this case a feature that is similar to "Dimensions as Columns", but for item specifications.

For example:

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Config. XML Exchange", 'OnAfterAddTableAttributes', '', false, false)]
local procedure OnAfterAddTableAttributes(ConfigPackageTable: Record "Config. Package Table"; var PackageXML: DotNet XmlDocument; var TableNode: DotNet XmlNode)
var
    FieldNode: DotNet XmlNode;
begin
    if ConfigPackageTable."Item Spec. as Columns" then begin
        FieldNode := PackageXML.CreateElement(ConfigXMLExchange.GetElementName(ConfigPackageTable.FieldName("Item Spec. as Columns")));
        FieldNode.InnerText := '1';
        TableNode.AppendChild(FieldNode);
    end;
end;