Skip to content

Extending Reports with the DMS Barcode

In this documentation we will create an extension that extends a report in Business Central with DMS. Extending a report with DMS 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 DMS 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 DMS module must be licensed.
  • CORE by Simova must be available in the extension as a reference.
  • DMS by Simova must be present in the extension as a reference.

Extension of RDLC Reports with a DMS Barcode:

  1. We will now apply a DMS Barcode to a report you have selected.
  2. Please create a ne .al file in VS Code.
  3. Now insert the following code into the newly created file:
AL
reportextension 5227509 "DMSDI_EXT Test" extends XXX
{
    dataset
    {
        add(Header)
        {
            column(Global_Barcode; GlobalBarcode)
            { }
        }
        modify(Header)
        {
            trigger OnAfterAfterGetRecord()
            var
                LocalBarcodeText: Text;
                LocalEnumSIMDMSDITypeOfBarcodes: Enum "SIM_DMSDI Type of Barcodes";
                LocalSIMDMSDIBarcodeMgt: Codeunit "SIM_DMSDI Barcode Management";
                LocalRRef: RecordRef;
            begin
                LocalRRef.Get(Header.RecordId());
                LocalBarcodeText := LocalSIMDMSDIBarcodeMgt.CreateBarcode(LocalRRef, Header."No.", '', XXX, false);
                GlobalBarcode := LocalSIMDMSDIBarcodeMgt.CreateLabel(LocalBarcodeText, 250, 600, true, Format(LocalEnumSIMDMSDITypeOfBarcodes::Code128), 'PNG');
            end;
        }
    }
    var
        GlobalBarcode: Text;
}

Info

In the enum "LocalEnumSIMDMSDITypeOfBarcodes" all supported types of barcodes are stored. To change the barcode type, select the corresponding value of the enum.

  1. Change the "XXX" to the report you want to edit.
  2. Publish this extension.
  3. Open the personalised report design in Business Central.
  4. Click on the action "New".
  5. Enter the report ID of the report you want to extend with the barcode.
  6. Select RDLC Layout.
  7. Open the .rdl file.
  8. Under the "Insert" tab, you must now add an image to the layout: image
  9. Find a place where you want to place the barcode.
  10. Right-click on the image you have addes & press "Image properties".
  11. The following changes have to be made:
    1. General:
      1. Name -> Barcode
      2. Image origin -> Database
      3. Use this field -> =System.Convert.FromBase64String(Fields!Global_Barcode.Value)
      4. Use this MIME type -> image/bmp
    2. Size:
      1. Display -> Fit Proportional
    3. Visibility:
      1. Expression -> =IsNothing(Fields!Global_Barcode.Value) OR (Globals!PageNumber>1)
  12. Save the .rdl file.
  13. Open the Personalised Report Design again in Business Central and click on the entry you have created
  14. Click on the "Import Layout" action under the Layout tab and select the .rdl file you edited.
  15. Go to the report layout selection.
  16. Select the report you have edited and change the layout to the one you have just created.
  17. When you print this report, a barcode should be printed.

Extension of Word Reports with a DMS Barcode:

  1. Apply a DMS Barcode to a report you have selected.
  2. Create a new .al file in VS Code.
  3. 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.:
AL
reportextension 5227509 "DMSDI_EXT Test" extends XXX
{
    dataset
    {
        add(Header)
        {
            column(Global_Barcode; GlobalRecordSIMCORETempTable."Blob 1")
            { }
        }
        modify(Header)
        {
            trigger OnAfterAfterGetRecord()
            var
                LocalSIMDMSDIBarcodeMgt: Codeunit "SIM_DMSDI Barcode Management";
                LocalCodeunitBase64Convert: Codeunit "Base64 Convert";
                LocalEnumSIMDMSDITypeOfBarcodes: Enum "SIM_DMSDI Type of Barcodes";
                LocalRecordRef: RecordRef;
                LocalOutStream: OutStream;
                LocalBarcodeText: Text;
                LocalBarcodeBase64Text: Text;
            begin
                LocalRecordRef.Get(Header.RecordId());
                LocalBarcodeText := LocalSIMDMSDIBarcodeMgt.CreateBarcode(LocalRecordRef, Header."No.", '', XXX, false);
                LocalBarcodeBase64Text := LocalSIMDMSDIBarcodeMgt.CreateLabel(LocalBarcodeText, 250, 600, true, Format(LocalEnumSIMDMSDITypeOfBarcodes::Code128), 'PNG');
                GlobalRecordSIMCORETempTable."Blob 1".CreateOutStream(LocalOutStream);
                LocalCodeunitBase64Convert.FromBase64(LocalBarcodeBase64Text, LocalOutStream);
            end;
        }
    }
    var
        GlobalRecordSIMCORETempTable: Record "SIM_CORE Temp Table";
}

Info

In the enum "LocalEnumSIMDMSDITypeOfBarcodes" all supported types of barcodes are stored. To change the barcode type, select the corresponding value of the enum.

  1. Change the "XXX" to the report you want to edit.
  2. Publish this extension.
  3. Open the word file of the report.
  4. Under the "Developer" tab, you need to select "XML Mapping Pane": image
  5. Select the added line and add it as an image: image
  6. Save the Word file.
  7. When you print this report, a barcode should be printed.