How to Add a Hyperlink to a Role Center in Business Central
Sometimes, you may want to quickly add a button on the Role Center page that opens an external website (e.g., company portal, Microsoft docs, etc.). This can be done by extending the Role Center and adding a custom action that uses the Hyperlink system function in AL.
Code Example
Codeunit
codeunit 50100 URLDisplay
{
trigger OnRun()
begin
Hyperlink('https://www.microsoft.com/en-us/dynamics-365/products/business-central');
end;
}
Page extension
pageextension 50100 MyExtension extends "Business Manager Role Center"
{
actions
{
addbefore("Sales Quote")
{
action(AddHyperlink)
{
Caption = 'URL Display';
ApplicationArea = All;
Image = link;
RunObject = codeunit URLDisplay;
}
}
}
}
Explanation of the Code
-
Creating the Codeunit (URLDisplay)
-
We created a new
codeunit
namedURLDisplay
. -
Inside the
OnRun()
trigger of this codeunit, we used theHyperlink()
function to open the Business Central product page in the browser. -
The purpose of this codeunit is to encapsulate the action of opening the hyperlink.
👉 Why? Because Role Center pages do not support the
trigger OnAction()
directly on actions. To work around this, we run a codeunit instead. -
-
Extending the Role Center Page
-
We extended the Business Manager Role Center page.
-
In the
actions
section, we inserted a new action before the “Sales Quote” action. -
The action has:
-
A caption →
"URL Display"
-
An icon →
Image = link;
-
A run object →
RunObject = codeunit URLDisplay;
-
This means when the user clicks the button on the Role Center, the system will execute the codeunit, and that codeunit will in turn open the hyperlink.
-
Result
Once you deploy this extension, a new “URL Display” button will appear in your Role Center.
Clicking it will immediately open the defined URL in the browser.
Thanks For Reading...!!😊
This was originally posted here.
*This post is locked for comments