1D & 2D Barcodes in Business Central 19.1

by Mar 20, 2022AL Language

Home 9 Development 9 AL Language 9 1D & 2D Barcodes in Business Central 19.1

Business Central (cloud-only!) includes one-dimensional (1D) barcode fonts since Microsoft Dynamics 365 Business Central 2020 wave 2 (17.0) was released in October 2020. It is a great improvement to how developers can handle requirements from their clients to print various reports with different types of bar codes.

However, one of the most missing features was 2D codes that are more and more used by automation in industry and warehouses. The two-dimensional (2D) barcode is, for example, a QR Code or Aztec code with an incredible number of various usage. Therefore Microsoft added new support for 2D barcodes with the latest update of Microsoft Dynamics 365 Business Central 2021 wave 2 (19.1), released during the last days of the previous year in December 2021.

This article will look at how to create 2D (but also 1D) barcodes.

One-Dimensional (1D) barcodes

All the information in One-Dimensional barcodes is organized horizontally in bar and space widths and read left to right by a scanner. It is still the most common barcode in use; however, 1-D barcodes are less effective in automatic processes as they are harder to read by machines.

Supported types

    • Code39
    • Code93
    • Code128
    • Codabar
    • Interleave 2 of 5
    • MSI Plessey
    • USPS Postnet
    • UPC-A
    • UPC-E
    • EAN-8
    • EAN-13

Create 1-D barcode

Creating any of the barcodes listed above is really easy as Microsoft added all required functions and encapsulated the logic internally so we do not have to care about specific details.

The most important objects are Enum “Barcode Symbology” and Interface “Barcode Font Provider”. The enum contains (as of now, 2022-03-10) only one value – IDAutomation1D. This enum also contains an implementation of required methods from Interface “Barcode Font Provider”.

See the code below to understand how to create barcode text in a specific format for EAN13. To use another barcode format, just change the first line and choose a different format from “Barcode Symbology”.

Then we have to add the barcode to the report itself. Just add your variable (BarCodeEAN13 in the picture above) as a Column of your DataItem and show the Column in the report as any other field from your data item.

Now the annoying part… You have to set the right Font (Right Click on your field with barcode data field -> “Text Box Properties” -> “Font”) based on the selected barcode type. Usually, you do not have those fonts installed locally (as they are paid and Microsoft licensed them only for cloud BC version) so you can not choose them from installed fonts.

So, instead of choosing the font using the dropdown menu, you have to write down the font by yourself. And how to find which font to use? The easiest way is to go through Microsoft Docs (see here), find the right link in the table based on your selected barcode type and open the “See…” link).

For example Code128 barcode type
Once you click on the “See…” link in the table near the Code128 section, you will be redirected to the IDAutomation web page (https://www.idautomation.com/barcode-fonts/code-128/). IDAutomation is the owner of all these fonts (1-D and 2-D)  from whom Microsoft obtained the license. In addition, if you want to use the same way for developing barcodes even for Business Central on-premises, you have to buy the right license on the same page.

Back to the main topic… To find the font name, go to the “User Manual” section and find the “Purchased Font Name” section. It is usually a table with at least three columns. From all the columns, the first one contains the font name we have to put in the report builder. See the picture below. 

And that’s it. It is a super easy way for creating any barcode functionality!

Two-Dimensional (2D) barcodes

Information in Two-Dimensional barcodes (matrix code) is a newer version of barcodes. The biggest advantages are the ability to store significantly more information than 1-D barcodes and the better readability by machines even in smaller sizes.

Supported types

    • Aztec 2D
    • Data Matrix
    • Maxicode
    • PDF417
    • QR-Code

The creation of 2D barcodes is similar to 1D barcodes, just add “2D” to object names and that’s all. See the picture below.

Add the barcode string to the report the same way as for 1D barcodes.

And set the right font. It’s easier than 1D as all 2D barcode types share the same font. Details can be found on the same page as for 1D barcodes.

And results as expected.

Recent Articles from the category

BC Open Source? How to start?

BC Open Source? How to start?

BC Open Source? How to start? One of the most exciting news introduced last month in Lyon during Directions EMEA 2023 was the changes to the open-source initiative. This means that you can now contribute to the source code of the Base app and the System app, which are...

read more
Validate a FlowField Field. Wait? What?

Validate a FlowField Field. Wait? What?

Validate a FlowField Field. Wait? What? There are not many things in the AL Language that surprised me. However, last week, I found one such thing - I reviewed customizations made by another partner and had to analyze the OOTB code of the Demand Forecast matrix. I run...

read more
Dynamics NAV 2013 & Expired Cronus License

Dynamics NAV 2013 & Expired Cronus License

We found an interesting problem - we were not able to run the development environment for Dynamics NAV 2013. Whenever we tried to run the development client, we got the following error message: "Your program license has expired" and the development client has closed...

read more
Indirect Dependencies and Access Modifiers

Indirect Dependencies and Access Modifiers

Last week, there was a discussion on Yammer on how to get values from the "Sent Email" record when all fields are marked as Internal. I was surprised that many people do not know what can/can't access modifiers (such as local, protected, or internal) be used for. I...

read more

Sign Up for News

Certifications

Highest certification
Microsoft Data Management and
also in D365 Business Central

Microsoft Certified: Dynamics 365 Business Central Functional Consultant Associate

See other certifications here