Extending Reports with the Document Central Barcode
In this documentation we will create an extension that extends a report in Business Central with Document Central. Extending a report with Document Central code is used so that when a report is printed or a document is posted/converted, it is possible to automatically generate and add a Document Central Barcode during that process.
There are two ways to do this:
In the case of a custom report, you can insert the code directly into the report. In the case of other reports, you can create a report extension that executes the code. There is also a difference between Word reports and RDLC reports.
The following requirements must be met:
- The Document Central module must be licensed.
- CORE must be available in the extension as a reference.
- Document Central must be present in the extension as a reference.
Learn more about Creating a Word layout report in Microsoft Business Central.
Learn more about Creating a RDLC layout report in Microsoft Business Central.
Extension of RDLC Reports with a Document Central Barcode:
- We will now apply a Document Central Barcode to a report you have selected.
- Please create a ne .al file in VS Code.
- Now insert the following code into the newly created file:
Info
In the enum "LocalEnumSIMDITypeOfBarcodes" all supported types of barcodes are stored. To change the barcode type, select the corresponding value of the enum.
- Change the "XXX" to the report you want to edit.
- Publish this extension.
- Open the personalised report design in Business Central.
- Click on the action "New".
- Enter the report ID of the report you want to extend with the barcode.
- Select RDLC Layout.
- Open the .rdl file.
- Under the "Insert" tab, you must now add an image to the layout:
- Find a place where you want to place the barcode.
- Right-click on the image you have addes & press "Image properties".
- The following changes have to be made:
- General:
- Name -> Barcode
- Image origin -> Database
- Use this field -> =System.Convert.FromBase64String(Fields!Global_Barcode.Value)
- Use this MIME type -> image/bmp
- Size:
- Display -> Fit Proportional
- Visibility:
- Expression -> =IsNothing(Fields!Global_Barcode.Value) OR (Globals!PageNumber>1)
- General:
- Save the .rdl file.
- Open the Personalised Report Design again in Business Central and click on the entry you have created
- Click on the "Import Layout" action under the Layout tab and select the .rdl file you edited.
- Go to the report layout selection.
- Select the report you have edited and change the layout to the one you have just created.
- When you print this report, a barcode should be printed.
Extension of Word Reports with a Document Central Barcode:
- Apply a Document Central Barcode to a report you have selected.
- Create a new .al file in VS Code.
- Insert the following code into the newly created file, or use your own blob field instead of the "SIM_CORE Temp Table" record blob field. This field must have only the subtype "Bitmap" or no subtype at all.:
Info
In the enum "LocalEnumSIMDMSDITypeOfBarcodes" all supported types of barcodes are stored. To change the barcode type, select the corresponding value of the enum.
- Change the "XXX" to the report you want to edit.
- Publish this extension.
- Open the word file of the report.
- Under the "Developer" tab, you need to select "XML Mapping Pane":
- Select the added line and add it as an image:
- Save the Word file.
- When you print this report, a barcode should be printed.