Bearbeiten

Teilen über


WordMergeDataItem Property

Version: Available or changed with runtime version 1.0.

Specifies the root-level DataItem that is used to generate separate reports for multiple records.

Applies to

  • Report

Syntax

WordMergeDataItem = MyDataItem; // MyDataItem must be present as a top-level dataitem in the report dataset

Remarks

The WordMergeDataItem property is only applied when rendering a report using a Word layout.

When you specify a dataitem in the WordMergeDataItem property, the Business Central server does a "Mail merge" between that data item (and the ones below it) and the Word layout when rendering the report using the Word layout.

In versions before Business Central 2024 release wave 2, Business Central Server implements the document merging by first generating the full merged document in Word. Then, it inserts Word sections to reset headers, footers, and page numbers between each document generated from the WordMergeDataItem. This behavior means that the use of Word sections in layouts for reports using the WordMergeDataItem property aren't allowed. At runtime, the Business Central Server shows an error message such as You cannot run the report because the {0} layout contains section breaks that conflict with the sections in the report. Remove the section breaks from the report layout, and then run the report.

Starting from version 2024 release wave 2, the Business Central Server implements the document merging by generating one document in Word for each row in the WordMergeDataItem. It then converts each document to a PDF and merges all the PDF documents. As a result, there's no longer the restriction on using Word sections in layouts for reports using the WordMergeDataItem property.

Example

The following example is showing how the WordMergeDataItem property is used on the "Standard Sales - Invoice" report when rendered with a Word layout.

Here, the Word layout is applied to each element in the Header dataitem. So, if you defined a different first page, page numbers, totals at the end, and similar report design elements in the Word layout, they're "reset" for each element in the Header dataitem.

report 1306 "Standard Sales - Invoice"
{
    // Other report properties set here

    WordMergeDataItem = Header;

    dataset
    {
        dataitem(Header; "Sales Invoice Header")
        {
            ...
        }
    }

    ...

    rendering
    {
        layout("StandardSalesInvoice.docx")
        {
            Type = Word;
            LayoutFile = './Sales/History/StandardSalesInvoice.docx';
            Caption = 'Standard Sales Invoice (Word)';
            Summary = 'The Standard Sales Invoice (Word) provides a simple layout that is also relatively easy for an end-user to modify.';
        }

        // more layouts here
    }
}

Creating a Word layout report
Working with Word layouts
Report object
Report overview