Dynamics 365 Business Central: How to add Notes (System Parts) from FactBox to a report

Dynamics 365 Business Central

Hi, Readers.
Today I’d like to briefly discuss a question I saw on the Business Central Forum last week, How to add Notes from FactBox to a report in Business Central.

As you might know, there are three system parts that you can define by using the systempart() keyword: Links, Notes and Summary:
System Parts: You can define the following system parts by using the systempart() keyword:

ValueDescription
LinksAllows the user to add links to a URL or path on the record shown in the page. For example, on an Item card, a user can add a link to the supplier’s item catalog. The links appear with the record when it’s viewed. When a user chooses a link, the target file opens.
NotesAllows the user to write a note on the record shown in the page. For example, when creating a sales order, a user can add a note about the order. The note appears with the item when it’s viewed.
SummaryAllows the user to view a summary of the record shown in the page on pages that display a summary by default. For example, on a Customer card, a user can see a summary of the customer’s sales history. The summary is available on pages when the Summarize capability is enabled on the Copilots and agents capabilities page. The summary appears with the record when it’s viewed. With 2025 release wave 2, the Summary part can be hidden in code on page objects, page extensions, and profiles. Use the DefaultSummaryPart keyword to refer to it in code. Learn more about how to use it in Business Central in Summarize records with Copilot.

Links and Notes were also mentioned when we discussed How to add Attachments, Links, Notes Factbox to any pages.

Actually their data is saved in the same table.
RecordLinks (2000000068):

Just different types.

PS: You cannot use system table 2000000068 in the Configuration Package.

table 2000000068 “Record Link”: Link (URL) is not too bad as it is text type field. But the Note is stored in a Blob.

Microsoft has prepared a standard conversion method for us in codeunit 447 “Record Link Management”.

    /// <summary>
    /// Read the Note BLOB
    /// </summary>
    /// <param name="RecordLink">The record link from which the note is read.</param>
    /// <returns>The note as a text.</returns>
    procedure ReadNote(RecordLink: Record "Record Link"): Text
    begin
        exit(RecordLinkImpl.ReadNote(RecordLink));
    end;

PS: Of course, you can also use InStream Data Type to export the Blob type to Text without using the standard method. However, please try to use the standard method for better performance. More details: How to export Work Description (Blob) in Sales Documents to excel

The next question is how this relates to the current data? Let’s look at a specific example: I added three Notes to the Sales Order.

When you open table 2000000068 “Record Link” directly, there are no fields for document type or document number. They are associated through Record ID. More details: How to quickly get the primary key values of the record (Record.GetPosition Method and RecordId Method)

Therefore, we cannot associate it with the Sales Header by adding Dataitem; this can only be done through code. However, this is not difficult.

Let me do a simple test: add all the Notes content to report 1305 “Standard Sales – Order Conf.”
PS: How to set multi-line text for a Blob Data Type field via AL

RDLC Layout:

Word Layout:

Great, 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)

reportextension 50123 StandardSalesOrderConfExt extends "Standard Sales - Order Conf."
{
    dataset
    {
        add(Header)
        {
            column(Notes; AllNotes)
            {
            }
        }
        modify(Header)
        {
            trigger OnAfterAfterGetRecord()
            var
                RecordLink: Record "Record Link";
                RecordLinkMgt: Codeunit "Record Link Management";
                TypHelper: Codeunit "Type Helper";
                CRLF: Text[2];
            begin
                AllNotes := '';
                CRLF := TypHelper.CRLFSeparator();
                RecordLink.Reset();
                RecordLink.SetRange("Record ID", Header.RecordId);
                RecordLink.SetRange(Type, RecordLink.Type::Note);
                RecordLink.SetAutoCalcFields(Note);
                if RecordLink.FindSet() then
                    repeat
                        if AllNotes = '' then
                            AllNotes := RecordLinkMgt.ReadNote(RecordLink)
                        else
                            AllNotes := AllNotes + CRLF + '-------------------------' + CRLF + RecordLinkMgt.ReadNote(RecordLink);
                    until RecordLink.Next() = 0;
            end;
        }
    }
    var
        AllNotes: Text;
}

PS: Dynamics 365 Business Central Blog Series: Links and Notes (System Parts)

END

Hope this will help.

Thanks for reading.

ZHU

コメント