web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

How to generate hyperlink for a record

(5) ShareShare
ReportReport
Posted on by 12


Basically for the business im working with, once a record is created, I have to generate a hyperlink like this

https://businesscentral.dynamics.com/?company=REFINEMAX%20INC&page=50169&filter=NewIncomingLotTable.ID%20IS%20%27%7b0232AB17-FE7E-4539-A449-EC4560CA3B5A%7d%27

The reason being is that I have to email this link to one of the workers who uses the system so they are notified when a new incoming lot is processed. However, I am having trouble with generating a working hyperlink as all the methods I;ve tried seem to complicated/hardcoded or just dont work for some reason. One function i've seen is the System.GetURL() function, for that this below is my syntax
 
recordURL := System.GetUrl(ClientType::Current, CompanyName, ObjectType::Page, 50171, assayRec, true);
 
This however returns a non-working hyperlink that errors out to a page that reads
Could not open the company.
Could not open the "REFINEMAX INCpage" company.

The company "REFINEMAX INCpage" does not exist.
Date and time: Mon, 06 Jan 2025 21:41:34 GMT
Microsoft Entra tenant: 0ff167b6-b89a-4c57-a41d-298ef6806a04
Operation: adc60dcb1fbe435993f07fff11cf1b55
and generates the link

https://businesscentral.dynamics.com/0ff167b6-b89a-4c57-a41d-298ef6806a04/BetaTesting/?company=CRONUS%20USA%2C%20Inc.page=50171

Which both has the incorrect company name, but also very barebones as it doesnt link to a specific record (there is not filters even though I set filters to true). Any help or any other ways I can generate a sharable link to a record on business central through code? Thank you
I have the same question (0)
  • Suggested answer
    Jeffrey Bulanadi Profile Picture
    6,939 on at
    How to generate hyperlink for a record

    Hi

    Thanks for the detailed breakdown—this is a common challenge when generating deep links to specific records in BC. The issue you're facing stems from two things:

    • Incorrect query parameter formatting (missing ampersand before page)
    • Improper filter construction when using System.GetUrl

    Here’s how to resolve it:

    1. Correct Usage of System.GetUrl
    The System.GetUrl() function is valid, but it doesn’t automatically format filters. You’ll need to manually append the filter string to the URL.

    al
    procedure GenerateRecordUrl(): Text
    var
        recordURL: Text;
        filterText: Text;
        pageID: Integer;
        assayRec: Record "NewIncomingLotTable";
    begin
        pageID := 50169; // Replace with your actual page ID
        recordURL := System.GetUrl(ClientType::Current, CompanyName, ObjectType::Page, pageID, assayRec, true);
    
        // Fix malformed URL by inserting ampersand before 'page'
        recordURL := recordURL.Replace('page=', '&page=');
    
        // Construct filter manually
        filterText := '&filter=ID IS ''' + Format(assayRec.ID) + '''';
    
        // Append filter to URL
        recordURL := recordURL + filterText;
    
        exit(recordURL);
    end;
     

    2. Common Pitfalls to Avoid

    • Ensure CompanyName is URL-encoded (e.g., REFINEMAX INC becomes REFINEMAX%20INC)
    • Always insert & before page= and filter= manually
    • Use Format() to convert GUIDs or record IDs to string safely
    • Confirm the record is retrieved before generating the URL
     

    Helpful References


    Here’s a link that showcase a correct formatted deep link:
    Dynamics 365 Lab – Share Readable Deep Links

    If you find this helpful, feel free to mark this as the suggested or verified answer.


    Cheers
    Jeffrey

  • CU09070734-0 Profile Picture
    on at
    How to generate hyperlink for a record
    To generate a hyperlink for a record in Dynamics 365 Finance and Operations (D365 F&O), you can create a URL that deep links directly to a specific form and record.
  • Suggested answer
    Mano Dharmalingam Profile Picture
    20 on at
    How to generate hyperlink for a record

    Hi,

    I believe the issue is not related to the unavailability of the company in the URL but rather the incorrect structure of the URL. Specifically, there should be an "&" added near "page" for the URL to be valid.

    To address this, I've implemented the following code to generate the URL for a specific record from the purchase header. Please review and let me know if this solution works for you:

    action("GetSystemURL")
                    {
                        Caption = 'Get System URL';
                        ApplicationArea = All;
                        trigger OnAction()
                        var
                            ObjID: Integer;
                            TextURL: Text;
                            PurchaseHeaderRec: Record "Purchase Header";
     
                        begin
                            if PurchaseHeaderRec.get(PurchaseHeaderRec."DocumentType"::Order, rec."No.") then begin
                                // Retrieve the object ID by parsing the ObjectID and calling the procedure
                                ObjID := 50;
     
                                // Generate the URL using System.GetUrl
                                TextURL := System.GetUrl(
                                    CurrentClientType,
                                    CompanyName,
                                    ObjectType::Page,
                                    ObjID,
                                    PurchaseHeaderRec,
                                    true
                                );
     
                                // Ensure the generated URL contains proper query parameters
                                TextURL := FormatUrl(TextURL, PurchaseHeaderRec);
     
                                // Display the resulting URL
                                Message('%1', TextURL);
                               
                            end;
                        end;
                    }
     
        /// <summary>
        /// Formats a URL string to ensure proper handling of query parameters.
        /// </summary>
        /// <param name="Url">The URL to format.</param>
        /// <returns>The formatted URL.</returns>
        procedure FormatUrl(Url: Text; PurchHeaderRec: Record "Purchase Header"): Text
        var
            filterValue: Text;
            pageFilter: text;
            LBLFilter: Label ' IS ';
            LBLCaption: Label 'No.';
        begin
            Url := Url.Replace('page', '&page');
            filterValue := LBLFilter + '''' + PurchHeaderRec."No." + ''''; // Replace with the actual filter value
            pageFilter := '''' + LBLCaption + '''' + filterValue;
            Url := Url + '&filter=' + pageFilter;
            Url := Url.Replace('filter', '&filter');
            exit(Url);
        end;
     
     
     
     
     
     
    Thanks,
    Mano Dharmalingam
  • Suggested answer
    Mano Dharmalingam Profile Picture
    20 on at
    How to generate hyperlink for a record

    Hi,

    I believe the issue is not related to the unavailability of the company in the URL but rather the incorrect structure of the URL. Specifically, there should be an "&" added near "page" for the URL to be valid.

    To address this, I've implemented the following code to generate the URL for a specific record from the purchase header. Please review and let me know if this solution works for you:

    action("GetSystemURL")
                    {
                        Caption = 'Get System URL';
                        ApplicationArea = All;
                        trigger OnAction()
                        var
                            ObjID: Integer;
                            TextURL: Text;
                            PurchaseHeaderRec: Record "Purchase Header";
     
                        begin
                            if PurchaseHeaderRec.get(PurchaseHeaderRec."Document Type"::Order, rec."No.") then begin
                                // Retrieve the object ID by parsing the ObjectID and calling the procedure
                                ObjID := GetObjectIdByName(DelStr(ObjectID, 1, 5));
     
                                // Generate the URL using System.GetUrl
                                TextURL := System.GetUrl(
                                    CurrentClientType,
                                    CompanyName,
                                    ObjectType::Page,
                                    ObjID,
                                    PurchaseHeaderRec,
                                    true
                                );
     
                                // Ensure the generated URL contains proper query parameters
                                TextURL := FormatUrl(TextURL, PurchaseHeaderRec);
     
                                // Display the resulting URL
                                Message('%1', TextURL);
                               
                            end;
                        end;
                    }
     
        /// <summary>
        /// Formats a URL string to ensure proper handling of query parameters.
        /// </summary>
        /// <param name="Url">The URL to format.</param>
        /// <returns>The formatted URL.</returns>
        procedure FormatUrl(Url: Text; PurchHeaderRec: Record "Purchase Header"): Text
        var
            filterValue: Text;
            pageFilter: text;
            LBLFilter: Label ' IS ';
            LBLCaption: Label 'No.';
        begin
            Url := Url.Replace('page', '&page');
            filterValue := LBLFilter + '''' + PurchHeaderRec."No." + ''''; // Replace with the actual filter value
            pageFilter := '''' + LBLCaption + '''' + filterValue;
            Url := Url + '&filter=' + pageFilter;
            Url := Url.Replace('filter', '&filter');
            exit(Url);
        end;
        /// <summary>
        /// Retrieves the Object ID for a given Object Name within the Page object type.
        /// </summary>
        /// <param name="ObjectName">Name of the object to find.</param>
        /// <returns>The Object ID if found; otherwise, 0.</returns>
        procedure GetObjectIdByName(ObjectName: Text): Integer
        var
            AllObjWithCaptionRec: Record AllObjWithCaption;
        begin
            AllObjWithCaptionRec.Reset();
            AllObjWithCaptionRec.SetRange("Object Type", AllObjWithCaptionRec."Object Type"::Page);
            AllObjWithCaptionRec.SetRange("Object Name", ObjectName);
            if AllObjWithCaptionRec.FindFirst() then
                exit(AllObjWithCaptionRec."Object ID");

            exit(0);
        end;
     
     
     
     
     
     
    Thanks,
    Mano Dharmalingam
     
  • Alexander Drogin Profile Picture
    262 on at
    How to generate hyperlink for a record
    I don't think it's the GetUrl function that is to blame here.
    First of all, regarding the incorrect company name - the URL is missing an ampersand character between the company name and the next parameter. Probably the generated URL is reformatted when you copy it. Check the value of recordURL variable in the debugger, it must look like this 
    ?company=CRONUS%20USA%2C%20Inc.&page=50171
     
    As for the filters, does you variable assayRec has any filters applied? This function works perfectly for me and adds filters if the record is filtered.
  • Suggested answer
    Ramiz Profile Picture
    597 on at
    How to generate hyperlink for a record
    Hi, 

    You can try using this.
     
    Hyperlink(GetUrl(ClientType::Current, CompanyToOpen, ObjectType::Page, Page::"Warehouse Shipment", WarehouseShipmentHeader))
     
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    18,914 Super User 2025 Season 2 on at
  • Suggested answer
    YUN ZHU Profile Picture
    89,902 Super User 2025 Season 2 on at
    How to generate hyperlink for a record
    Hi, hope the following can give you some hints.
    Dynamics 365 Business Central: Filtering Data by the Web Client URL
     
    Thanks.
    ZHU

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,869 Super User 2025 Season 2

#2
Sumit Singh Profile Picture

Sumit Singh 2,484

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,242

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans