Dynamics 365 Business Central: Can we download the logo of an extension from BC?

Dynamics 365 Business Central

Hi, Readers.
Today I would like to talk about an interesting topic, can we download the logo of an extension from Business Central?

As you might know, this is specified by the logo setting in the app.json file when you customize your extension.

App.json file: required for AppSource submission

For example, Base Application:

In Business Central:

If no logo is set, it will be displayed as follows by default.

Also this logo is usually used as an offer logo, so when you create your own logo, it is best to meet the following structure.

For example, Shopify Connector: on the marketplace search results.

Actually, we can download this logo.
In codeunit 2504 “Extension Management”: procedure GetExtensionLogo (Gets the logo of an extension)

Let me do a simple test. In the Extension list, add an action to download the logo of the selected extension. If it does not exist, an error will be prompted.
But first of all, standard Extension Management (2500, List) page cannot be extended.

The application object or method ‘Extension Management’ has scope ‘OnPrem’ and cannot be used for ‘Extension’ development.ALAL0296

When we discussed how to get the list of Extension ID (App ID), Extension Name, Publisher, etc. via AL, we use table 2000000153 “NAV App Installed App”. We can use the same method this time.

For example,

Great.

Then add a new action to download the logo.

Test:

Looks good.

Test video:

The last thing I want to mention is that downloading the logo will not be restricted by the Resource exposure policy setting. Even if allowDebugging or allowDownloadingSource is set to false, the logo will be downloaded normally. More details: Richer access control for extension source in cloud environments (‘showMyCode’ -> ‘resourceExposurePolicy’)

Interesting, give it a try!!!😁

Source code: Github (Please note that the source code is for reference only, you can improve it according to your own needs)

page 50105 "ZY Installed App"
{
    ApplicationArea = All;
    Caption = 'Installed App';
    PageType = List;
    SourceTable = "NAV App Installed App";
    UsageCategory = Lists;
    Editable = false;
    InsertAllowed = false;
    DeleteAllowed = false;
    ModifyAllowed = false;
    SourceTableView = sorting(Name)
                      order(ascending)
                      where(Name = filter(<> '_Exclude_*'));

    layout
    {
        area(content)
        {
            repeater(General)
            {
                field("App ID"; Rec."App ID")
                {
                    ToolTip = 'Specifies the ID of the extension.';
                }
                field(Name; Rec.Name)
                {
                    ToolTip = 'Specifies the name of the extension.';
                }
                field(Publisher; Rec.Publisher)
                {
                    ToolTip = 'Specifies the value of the Publisher field.';
                }
                field(VersionNumber; Format(VersionNumber))
                {
                    Caption = 'Version';
                    ToolTip = 'Specifies the version number of the extension.';
                }
                field("Published As"; Rec."Published As")
                {
                    ToolTip = 'Specifies the value of the Published As field.';
                }
            }
        }
    }

    actions
    {
        area(processing)
        {
            action(DownloadExtensionLogo)
            {
                ApplicationArea = All;
                Caption = 'Download Extension Logo';
                Promoted = true;
                PromotedCategory = Process;
                Image = Download;

                trigger OnAction()
                var
                    ExtensionMgt: Codeunit "Extension Management";
                    TempBlob: Codeunit "Temp Blob";
                    InStr: InStream;
                    ImageName: Text;
                begin
                    Clear(TempBlob);
                    ImageName := '';
                    ExtensionMgt.GetExtensionLogo(Rec."App ID", TempBlob);
                    TempBlob.CreateInStream(InStr);
                    if InStr.Length <> 0 then begin
                        ImageName := Rec.Name + '.png';
                        DownloadFromStream(InStr, '', '', '', ImageName);
                    end else
                        Message('No logo found for this extension.');
                end;
            }
        }
    }

    var
        VersionNumber: Version;

    trigger OnAfterGetRecord()
    begin
        VersionNumber := Version.Create(Rec."Version Major", Rec."Version Minor", Rec."Version Build", Rec."Version Revision");
    end;
}

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL