Creating and Copying Layouts
A Dynamics 365 Business Central report is made up of the following two components:
- Report Object: A report object defines the report dataset (i.e., based on the report schema, which include the dataitems, fields/columns and parameters) and request page. Its definition is found in the code of a Dynamics 365 Business Central (AL) extension.
- Layout: A layout defines how the report dataset should be presented when printed or exported to a file. You can use a report designer to edit the layout of a report.
If you want to design a layout for one of your document reports, then it is best to get started by creating a copy of an existing, extension-provided report layout to create a new user-defined report layout that you can edit. However, if you want to, you can also choose to create an entirely new, blank Document Creator layout for your document reports.
Creating a New Layout¶
Tip
Use the Document Creator User-Defined Report Layouts page for creating and editing layouts in your Business Central Sandbox environment.
To create a new, report layout, you first need to have a report object that the layout will target. You can use one of the report objects from the Microsoft Base Application, use a report object from the Document Creator extension, or from any other extension.
If you have a report object, then you can create a new Document Creator report layout for the report on the Report Layouts or Document Creator User-Defined Report Layouts page as follows:
Creating a New Blank Layout¶
-
Invoke the New Layout... action.
-
Choose New blank layout and choose OK.
-
Enter/Select the Report ID of the target report object.
- Enable Insert Document Creator Layout.
- Select OK.
The figure below shows the inputs on the Add New Blank Document Creator Layout dialog page to create a new, blank Document Creator layout for report 11249662 "Sales – Invoice":
After pressing "OK", a new record will have been created for report 11249662 "Sales – Invoice" with layout name "My Custom Sales Invoice Layout".
Note that you can always choose to rename the layout using the standard Edit Info action on the Report Layouts page.
Creating a New Layout based on a Built-In Layout¶
-
Invoke the New Layout... action.
-
Choose Copy from built-in layout and choose OK.
-
Select a built-in report layout from the list to copy as a new layout.
- By default the Layout Name will be set to "Copy of <Original Name>". You can freely change this name. (Optional)
- You can also change the target report object for the new layout if you enable the Change Report (Dataset) option. If this option is enabled, you can enter/select the Report ID of the new target report object. (Optional)
- Select OK.
Copying a Layout¶
To copy a layout from an existing Document Creator report layout record to a new record on the Report Layouts page, follow these steps:
- Select a report layout record from which to copy the layout.
-
Invoke the Copy action.
-
By default the Layout Name will be set to "Copy of <Original Name>". You can freely change this name. (Optional)
- You can also change the target report object for the new layout if you enable the Change Report (Dataset) option. If this option is enabled, you can enter/select the Report ID of the new target report object. (Optional)
- Select OK.
A new record will have been created containing a copy of the layout of the earlier selected record.
Caution
If you enable the Change Report (Dataset) option and change the target report object, then please take into account that the schema of the report objects might be different. Therefore, the layout may not work directly, which means you will need to edit it first to make sure it matches the new schema.
Extension-Provided Layouts¶
Caution
The information below is only relevant to Business Central (AL) extension developers. If you are not planning to develop a Business Central extension, then you can freely skip this section.
Starting from the Microsoft Dynamics 365 Business Central 2022 release wave 1 (April 1st, 2022, version 20.0) it is possible to have multiple extension-provided report layouts.
This also means that you include one or more Document Creator layouts in an AL report
or reportextension
object in your Business Central extension.
In the report
object definition or in a reportextension
object it is possible to define the layouts that should be shipped with the app(s) that (collectively) define the report object that produces the dataset in a new rendering
section of the object.
A reportextension
can add additional layouts for the report, but note that it cannot modify or remove the existing layouts provided by the original report
object or other reportextension
objects for the report.
Document Creator report layouts are defined as External (in AL rendering
sections, this layout type is named Custom
) layouts with the MimeType
set to reportlayout/dcrx
.
You can include a Document Creator layout for a report in your app by adding a layout
section with the properties set as follows:
AL: Rendering section sample with Document Creator .dcrx layout files | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
When the app is installed, the newly added, extension-provided report layouts can all be found on the Report Layouts page.