Business Central AL ModuleInfo

In the AL Language, the programming language behind Microsoft Dynamics 365 Business Central, the ModuleInfo Data Type provides information about an application. I have often used the ModuleInfo returned by the NavApp to check specific application version information.
The NavApp DataType includes information about a NavApp and has a few methods that retrieve a ModuleInfo for the Calling, Current or Specific application.

local procedure ModuleInfoDemo(ModuleInfoReqType: enum "DVLPR ModuleInfo ReqType");
    var
        ModuleInfo: ModuleInfo;
    begin
        case ModuleInfoReqType of
            "DVLPR ModuleInfo ReqType"::Calling:
                NavApp.GetCallerModuleInfo(ModuleInfo);
            "DVLPR ModuleInfo ReqType"::Current:
                NavApp.GetCurrentModuleInfo(ModuleInfo);
            "DVLPR ModuleInfo ReqType"::Specific:
                NavApp.GetModuleInfo('{c512d720-63b9-4b26-b062-a0c09b4ed322}', ModuleInfo);
        end;

        PopulatePageFields(ModuleInfo);
    end;

    local procedure PopulatePageFields(ModuleInfo: ModuleInfo)
    var
        i: Integer;
        ModuleDependencyInfo: ModuleDependencyInfo;
        DependencyNames: Text;
        AppVersion,
        DataVersion : Version;

    begin
        AppVersion := ModuleInfo.AppVersion;
        DataVersion := ModuleInfo.DataVersion;
        Clear(DependencyNames);

        ModuleID := Format(ModuleInfo.Id);
        ModuleName := ModuleInfo.Name;
        ModulePublisher := ModuleInfo.Publisher;
        ModuleAppVersion := Format(AppVersion);
        ModuleDataVersion := Format(DataVersion);
        ModulePackageId := Format(ModuleInfo.PackageId);

        for i := 1 to ModuleInfo.Dependencies().Count() do begin
            ModuleInfo.Dependencies.Get(i, ModuleDependencyInfo);
            DependencyNames += ModuleDependencyInfo.Name + ',';
        end;

        ModuleDependency := DependencyNames;
    end;

For more information, see ModuleInfo Data Type and NavApp Data Type 

Note: The code listed in this article is for informational and demonstration purposes only. This content was created referencing Microsoft Dynamics 365 Business Central 2022 Wave 1

Permanent link to this article: https://www.dvlprlife.com/2022/07/business-central-al-moduleinfo/

Leave a Reply

Your email address will not be published.