Dynamics 365 Business Central: How to detect whether a specific extension is installed in AL

Dynamics 365 Business Central

Hi, Readers.
A few days ago, I was asked a interesting question about is there any way to detect if a specific extension is installed in AL?

Yes, of course, there is a very easy way to do this, the premise is that you need to know the app id of the Extension. In this post, I would like to talk about how to detect whether a specific extension is installed in AL.

About half a year ago, we have discussed how to get information about the extension that is currently running in AL, at that time we used ModuleInfo Data Type and NavApp.GetCurrentModuleInfo Method.

This time we can use NavApp.GetModuleInfo Method.

NavApp.GetModuleInfo(Guid, var ModuleInfo) Method: Gets information about the specified AL application.

[Ok := ]  NavApp.GetModuleInfo(AppId: Guid, var Info: ModuleInfo)

Return Value: true if the information could be retrieved, otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.

So this method will return false if the supplied AppId is not installed, otherwise, you’ll get all module info about the installed app.

Let’s do a small test.

I want to detect whether the following extension is installed.

Test Code:

pageextension 50144 ItemListExt extends "Item List"
{
    trigger OnOpenPage();
    var
        Info: ModuleInfo;
        InstalledMsg: Label 'The Extension is installed, and the extension name is %1.';
        NotInstalledMsg: Label 'The Extension is not installed.';
    begin
        if NavApp.GetModuleInfo('8ed41111-a4d2-4d39-ad0e-5f1200490e8f', Info) then
            Message(InstalledMsg, Info.Name)
        else
            Message(NotInstalledMsg);
    end;
}

Test Video:

Simple, isn’t It?😀 Give it a try.

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL