Extending Reports with the Document Inbound Barcode
This documentation explains how to extend a report in Business Central with a Document Inbound Barcode. The barcode is automatically generated and added during the report printing or when booking or converting a document.
Procedure
There are two approaches to achieve this:
-
Custom Reports:
In custom reports, you can directly integrate the required code into the report. -
Standard Reports:
For standard reports, you can create a report extension that implements the appropriate code.
Please note that there are differences between Word Reports and RDLC Reports that need to be considered during implementation.
Requirements
Before you begin, ensure that the following prerequisites are met:
- CORE must be referenced in the extension.
- Document Central must be referenced in the extension.
- Document Inbound must be referenced in the extension.
- Document Central must be properly licensed.
- Document Central and Document Inbound must be activated in the corresponding module setup.
Learn more about creating a Word Layout report in Microsoft Business Central.
Learn more about creating an RDLC Layout report in Microsoft Business Central.
Setup in Document Central
To ensure correct functionality, the following configurations must be made for the created/extended report in Document Central:
- A number series for the barcode must be set up in the mapping. The mapping must be based on the table of the report.
- In the Report Settings, the following points must be considered:
- A Barcode Content Type must be defined.
- Barcode Printing must be enabled.
Extending RDLC Reports
- In this section, we will add a Document Inbound barcode to a report of your choice.
- Create a new
.al
-file in Visual Studio Code or open an existing.al
-file that extends the desired report. -
Add the following code to the opened file:
Info
The Enum "LocalEnumSIMDITypeOfBarcodes" defines all supported barcode types. To change the barcode type, simply select the desired value from this Enum.
-
Replace "XXX" with the ID of the report you want to extend (e.g., 1306 for Sales Invoice).
- Publish the extension.
- Open Report Layouts in Business Central.
- Find the layout you want to extend and click "Update and Download Layout".
- Open the downloaded layout file.
- Add an image by selecting "Insert" -> "Picture".
- Position the added image where you want the barcode to appear.
- Right-click on the image and select "Image Properties".
- Make the following adjustments in the "Image Properties" dialog:
- General:
- Name: Barcode
- Image Source: Database
- Field to Use:
=System.Convert.FromBase64String(Fields!Global_Barcode.Value)
- MIME Type:
image/bmp
- Size:
- Display: Resize proportionally
- Visibility:
- Expression:
=IsNothing(Fields!Global_Barcode.Value) OR (Globals!PageNumber>1)
- Expression:
- General:
- Save the edited
.rdl
file. - Go back to Report Layouts in Business Central and add the edited layout:
- Select "New" to add a new layout, and upload the edited file.
- Alternatively, you can replace the existing layout with the edited file.
- Link the report to the newly created layout.
- When you print the report, the barcode should be displayed correctly.
Extending Word Reports
- In this section, we will add a Document Inbound barcode to a selected report.
- Create a new
.al
-file in Visual Studio Code or open an existing.al
-file that extends the desired report. -
Add the following code to the opened file, or alternatively, use your own Blob field instead of the Blob field from the "SIM_CORE Temp Table" record. Ensure the field has the "Bitmap" subtype or no subtype defined.
Info
The Enum "LocalEnumSIMDITypeOfBarcodes" defines all supported barcode types. To change the barcode type, simply select the desired value from this Enum.
-
Replace "XXX" with the report ID you want to extend (e.g., 1306 for Sales Invoice).
- Publish the extension.
- Open the Word file of the report.
- Navigate to the "Developer" tab in the Word document and select "XML Mapping Pane".
- Right-click on "Global_Barcode".
- Select "Insert Content Control" and then "Picture".
- Position the picture where you want the barcode to appear in the document.
- Save the Word file.
- Go back to Business Central and upload the Word file as a layout.
- Link the edited layout to the corresponding report.
- When printing this report, the barcode will now be output.