New Features for Dynamics 365 Business Central 2021 release wave 1 (BC18): Use one-dimensional barcodes in reports (Business Central online)

Dynamics 365 Business Central

Hi, Readers.
Today I would like to discuss a new feature for Dynamics 365 Business Central 2021 release wave 1 (BC18).
Use one-dimensional barcodes in reports (Business Central online):

Feature details:

This release wave adds fonts to generate one-dimensional barcodes in Business Central production and sandbox environments. This means that any custom layouts using the fonts will work.

We have licensed the font packages provided by IDAutomation Inc.

We have also added a new AL module to make it easy for developers to encode strings in the different barcode symbologies that the fonts support.

You can start testing the fonts now. See the following articles for more information about font types and sizes:

https://www.idautomation.com/barcode-fonts/codabar/
https://www.idautomation.com/barcode-fonts/code-39
https://www.idautomation.com/barcode-fonts/code-93/
https://www.idautomation.com/barcode-fonts/code-128/
https://www.idautomation.com/barcode-fonts/interleaved-2of5/
https://www.idautomation.com/barcode-fonts/msi/

As you might know, in NAV and BC On-premises environments, we can use barcodes easily by installing a font. But we can’t do that in a SaaS environment.
Fortunately, starting from BC18.0, we can use the following font directly to display the barcode without any external services.
Codabar Font Package:
Codabar – A numeric barcode encoding numbers with a slightly higher density than Code 39.

Code 39 Barcode Font Package:
Code 39 – An alpha-numeric barcode that encodes uppercase letters, numbers and some symbols; it is also referred to as Barcode/39, the 3 of 9 Code and LOGMARS Code.

Code 93 Barcode Fonts:
Code 93 – Similar to Code 39, but requires two checksum characters.

Code 128 Barcode Font Package:
Code 128 – Alpha-numeric barcode with three character sets. Supports Code-128, GS1-128 (Formerly known as UCC/EAN-128) and ISBT-128.

Interleaved 2 of 5 (ITF) Barcode Font Package:
Interleaved 2 of 5 – The Interleaved 2 of 5 barcode symbology encodes numbers in pairs, similar to Code 128 set C.

MSI Plessey Font Package:
MIS – The MSI Plessey barcode symbology was designed in the 1970s by the Plessey Company in England and has practiced primarily in libraries and retail applications.

In fact, I’ve tested this feature since last month, but none of them could display the barcode correctly until yesterday when I had the pleasure of reading Roberto Stefanetti‘s blog, Barcode in Business Central Cloud! I finally realized what I was missing before.

The key point is that although the font is not installed locally, the correct font must be set on the Report Layout. Otherwise, the barcode will not be displayed, or the displayed barcode can not be scanned.

You can read Roberto Stefanetti‘s blog directly, which has very detailed explanations.
In this post, I will test all type again, hope this also helps.

First of all, I don’t have any demo fonts installed locally.

Let’s start.
Create a new report that displays Item information. Then add No., Description and six kinds of Barcode.

Code for generating Barcode:
For example: Codabar and Code 128.

Note: ValidateInput method will throw a error if the string contains characters that not supported by the barcode font.

Input text 1896-S contains invalid characters for the chosen provider IDAutomation 1D Barcode Provider and encoding symbology Codabar

Then create a layout for the report.
This time I will use RDLC layout.

Note: Since the font is not installed locally, and you must set the right font for the barcode field.
Right-click the text box, then choose Text Box Properties.

Fill in the font used by Barcode.

You can find these fonts on the barcode fonts website (idautomation.com).

For example, Code 39 Font Names and Application Data (idautomation.com)

My test fonts: For reference only
Codabar: IDAutomationHCBL

Code 128: IDAutomationC128S

Code 39: IDAutomationHC39M

Code 93: IDAutomationC93M

Interleaved 2 of 5: IDAutomationHI25M

MSI: IDAutomationMSIM

Publish the report and test.

Test video:

Scan test: Sorry not too clear

Source code: BarcodeTestForBC18

report 50100 ItemBarCode
{
    UsageCategory = Administration;
    ApplicationArea = All;
    DefaultLayout = RDLC;
    Caption = 'Item Barcodes';
    RDLCLayout = 'ItemBarcodes.rdl';

    dataset
    {
        dataitem(Item; Item)
        {
            DataItemTableView = sorting("No.");
            RequestFilterFields = "No.";
            RequestFilterHeading = 'Items';
            column(No_; "No.")
            {
            }
            column(Description; Description)
            {
            }
            column(Codabar; EncodeTextCodabar)
            {
            }
            column(Code128; EncodeTextCode128)
            {
            }
            column(Code39; EncodeTextCode39)
            {
            }
            column(Code93; EncodeTextCode93)
            {
            }
            column(Interleaved2of5; EncodeTextInterleaved2of5)
            {
            }
            column(MSI; EncodeTextMSI)
            {
            }


            trigger OnAfterGetRecord()
            begin
                GenerateCodabar();
                GenerateCode128();
                GenerateCode39();
                GenerateCode93();
                GenerateInterleaved2of5();
                GenerateInterMSI();
            end;

        }
    }
    local procedure GenerateCodabar()
    var
        BarcodeSymbology: Enum "Barcode Symbology";
        BarcodeFontProvider: Interface "Barcode Font Provider";
        BarcodeString: Text;
    begin
        BarcodeFontProvider := Enum::"Barcode Font Provider"::IDAutomation1D;
        BarcodeSymbology := Enum::"Barcode Symbology"::Codabar;
        BarcodeString := Item."No.";
        BarcodeFontProvider.ValidateInput(BarcodeString, BarcodeSymbology);
        EncodeTextCodabar := BarcodeFontProvider.EncodeFont(BarcodeString, BarcodeSymbology);
    end;

    local procedure GenerateCode128()
    var
        BarcodeSymbology: Enum "Barcode Symbology";
        BarcodeFontProvider: Interface "Barcode Font Provider";
        BarcodeString: Text;
    begin
        BarcodeFontProvider := Enum::"Barcode Font Provider"::IDAutomation1D;
        BarcodeSymbology := Enum::"Barcode Symbology"::Code128;
        BarcodeString := Item."No.";
        BarcodeFontProvider.ValidateInput(BarcodeString, BarcodeSymbology);
        EncodeTextCode128 := BarcodeFontProvider.EncodeFont(BarcodeString, BarcodeSymbology);
    end;

    local procedure GenerateCode39()
    var
        BarcodeSymbology: Enum "Barcode Symbology";
        BarcodeFontProvider: Interface "Barcode Font Provider";
        BarcodeString: Text;
    begin
        BarcodeFontProvider := Enum::"Barcode Font Provider"::IDAutomation1D;
        BarcodeSymbology := Enum::"Barcode Symbology"::Code39;
        BarcodeString := Item."No.";
        BarcodeFontProvider.ValidateInput(BarcodeString, BarcodeSymbology);
        EncodeTextCode39 := BarcodeFontProvider.EncodeFont(BarcodeString, BarcodeSymbology);
    end;

    local procedure GenerateCode93()
    var
        BarcodeSymbology: Enum "Barcode Symbology";
        BarcodeFontProvider: Interface "Barcode Font Provider";
        BarcodeString: Text;
    begin
        BarcodeFontProvider := Enum::"Barcode Font Provider"::IDAutomation1D;
        BarcodeSymbology := Enum::"Barcode Symbology"::Code93;
        BarcodeString := Item."No.";
        BarcodeFontProvider.ValidateInput(BarcodeString, BarcodeSymbology);
        EncodeTextCode93 := BarcodeFontProvider.EncodeFont(BarcodeString, BarcodeSymbology);
    end;

    local procedure GenerateInterleaved2of5()
    var
        BarcodeSymbology: Enum "Barcode Symbology";
        BarcodeFontProvider: Interface "Barcode Font Provider";
        BarcodeString: Text;
    begin
        BarcodeFontProvider := Enum::"Barcode Font Provider"::IDAutomation1D;
        BarcodeSymbology := Enum::"Barcode Symbology"::Interleaved2of5;
        BarcodeString := Item."No.";
        BarcodeFontProvider.ValidateInput(BarcodeString, BarcodeSymbology);
        EncodeTextInterleaved2of5 := BarcodeFontProvider.EncodeFont(BarcodeString, BarcodeSymbology);
    end;

    local procedure GenerateInterMSI()
    var
        BarcodeSymbology: Enum "Barcode Symbology";
        BarcodeFontProvider: Interface "Barcode Font Provider";
        BarcodeString: Text;
    begin
        BarcodeFontProvider := Enum::"Barcode Font Provider"::IDAutomation1D;
        BarcodeSymbology := Enum::"Barcode Symbology"::MSI;
        BarcodeString := Item."No.";
        BarcodeFontProvider.ValidateInput(BarcodeString, BarcodeSymbology);
        EncodeTextMSI := BarcodeFontProvider.EncodeFont(BarcodeString, BarcodeSymbology);
    end;

    var
        EncodeTextCodabar: Text;
        EncodeTextCode128: Text;
        EncodeTextCode39: Text;
        EncodeTextCode93: Text;
        EncodeTextInterleaved2of5: Text;
        EncodeTextMSI: Text;

}

Update 2021/04/15: Information from Dynamics 365 Business Central Launch Event 2021 release wave 1

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL