Dynamics 365 Business Central: How to open a page in a new browser tab via AL (Run an object in a new tab)

Dynamics 365 Business Central

Hi, Readers.
Last week I had answered a question on the forum about how to drilldown into the data of another company in Business Central. More details: Link.
This time I saw his additional questions, “when i drill down, can we open new tab?”
So in this post, I would like to talk about how to open a page in a new browser tab via AL.

As you know, there are many ways to use when we need to open another page in BC.
For example:

Page.Run() Method: Creates and launches a page that you specify.

Page.RunModal() Method: Creates, opens, and closes a page that you specify.

RunObject Property: Sets the object you want to run immediately when the action is activated.

But they all have one feature in common, and that is to open another page in the same tab. (The test page is from Collect data from different companies and Drilldown into the data of another company)

PS: Except for the Page.RunModal() method, you can choose the Open this page in a new window button in the upper-right corner or presse Alt+Shift+W to pop out a new window.

The page run by Page.RunModal() method do not have this button.

Now the windows client was completely removed, everything shifts to the web client (modern client). It basically runs in one tab. Of course, you can use multiple tabs manually. Or use the Multitask across multiple pages feature (Open this page in a new window).

Let’s go back to the topic, is there any way to open page in a new browser tab? Yes, we need to use the following method this time.

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

Syntax: System.Hyperlink(URL: String)

At runtime, a new tab is opened in the same browser window where Dynamics 365 Business Central is running. If you pass an empty string, then no browser window is opened.

System.GetUrl() Method: Generates a URL for the specified client target that is based on the configuration of the server instance. If the code runs in a multitenant deployment architecture, the generated URL will automatically apply to the tenant ID of the current user.

Syntax: String := System.GetUrl(ClientType: ClientType [, Company: String] [, ObjectType: ObjectType] [, ObjectId: Integer] [, Record: Record] [, UseFilters: Boolean])

So, we can do as follows.
For example: Open the customer list of the selected company.

Hyperlink(GetUrl(ClientType::Current, Rec.CompanyName, ObjectType::Page, Page::”Customer List”));

Source Code:

                Caption = 'Open Customer List';
                ApplicationArea = All;
                PromotedCategory = Process;
                Promoted = true;
                Image = Open;

                trigger OnAction()
                    Hyperlink(GetUrl(ClientType::Current, Rec.CompanyName, ObjectType::, Page::"Customer List"));
                    //Page.Run(Page::"Customer List");
                    //if Page.RunModal(Page::"Customer List") = Action::LookupOK then;

Test Video:

PS: Of course this method is not limited to Page, you can open other object types as well.


Hope this will help.




Copied title and URL