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

Notifications

Announcements

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
    YUN ZHU Profile Picture
    96,039 Super User 2025 Season 2 on at
    Hi, hope the following can give you some hints.
    Dynamics 365 Business Central: Filtering Data by the Web Client URL
     
    Thanks.
    ZHU
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    21,048 Super User 2025 Season 2 on at
  • Suggested answer
    Ramiz Profile Picture
    597 on at
    Hi, 

    You can try using this.
     
    Hyperlink(GetUrl(ClientType::Current, CompanyToOpen, ObjectType::Page, Page::"Warehouse Shipment", WarehouseShipmentHeader))
     
  • Alexander Drogin Profile Picture
    262 on at
    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
    Mano Dharmalingam Profile Picture
    20 on at

    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
     
  • Suggested answer
    Mano Dharmalingam Profile Picture
    20 on at

    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
  • CU09070734-0 Profile Picture
    on at
    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
    Jeffrey Bulanadi Profile Picture
    8,764 on at

    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

    Copy Links.png
    Copy Links 2.png

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

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,651

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 808 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 718 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans