Dynamics 365 Business Central: How to open BC Admin Center and M365 Admin Center via AL

Dynamics 365 Business Central

Hi, Readers.
Today I would like to share another mini tip about Business Central, how to open BC Admin Center and M365 Admin Center via AL.

The Business Central administration center provides a portal for administrators to do administrative tasks for a Business Central tenant. As long as you have permission, you can easily open it through the following action. More details about Supported Microsoft Entra roles for access.
Settings -> Admin Center:

The Microsoft 365 admin center gives users a central location to take care of common admin tasks, you can open it from App launcher in BC. More details: Overview of the Microsoft 365 admin center
App launcher -> Admin:

These two buttons are integrated into the BC platform, so we cannot see their standard code. What should we do if we want to add these two buttons to a BC page? For example, on the Users (9800, List) page.

The first thing that may come to mind is the hard-coded way, such as using the following two methods to directly open the link to the admin center.

System.GetUrl() Method: Generates a URL for the specified client target that is based on the configuration of the server instance.

System.Hyperlink Method: Passes a URL as an argument to an Internet browser, such as Windows Internet Explorer.

It can be done. But there are actually standard methods to do this.
codeunit 9085 “Microsoft 365 License”: procedure OpenBCAdminCenter and procedure OpenM365AdminCenter

We can do it simply.

Test video:

Very simple, 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)

pageextension 50119 UsersExt extends Users
{
    actions
    {
        addafter("Update users from Office")
        {
            action("Open Admin Center")
            {
                ApplicationArea = All;
                Caption = 'Open Admin Center';
                Image = Open;
                Promoted = true;
                PromotedCategory = Process;
                trigger OnAction()
                var
                    M365License: Codeunit "Microsoft 365 License";
                begin
                    // Opens the Business Central admin center.
                    M365License.OpenBCAdminCenter();
                end;
            }
            action("Open M365 Admin Center")
            {
                ApplicationArea = All;
                Caption = 'Open M365 Admin Center';
                Image = Open;
                Promoted = true;
                PromotedCategory = Process;
                trigger OnAction()
                var
                    M365License: Codeunit "Microsoft 365 License";
                begin
                    // Opens the M365 admin center.
                    M365License.OpenM365AdminCenter();
                end;
            }
        }
    }
}

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL