Warning: number_format() expects parameter 1 to be float, string given in /data/web/virtuals/7298/virtual/www/domains/kepty.cz/wp-includes/functions.php on line 425

1D & 2D Barcodes in Business Central 19.1

by Jan 10, 2022AL Language

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

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-01-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

DynamicsCon 2021 session recording available!

DynamicsCon 2021 session recording available!

Finally, recordings from DynamicsCon 2021 Autumn edition are available! Check the official youtube channel. It was a great conference with over 250 people during my live session! I definitely hope I will be able to attend the next in-person DynamicsCon as a speaker...

read more
Directions EMEA

Directions EMEA

Directions4Partners EMEA 2021 is still in progress here in Milan. I want to share all details about each day, but unfortunately, there are so many amazing things to see, watch and try I have almost no time. So today just a few words about the day before the...

read more
Field Level Permissions (Restricted Fields)

Field Level Permissions (Restricted Fields)

I just add a new project to my GitHub repositories. It is a new extension for Business Central that extends security functionalities with field-level permission. Using this extension, users are able to define who can or can not change specific fields in any table in...

read more
Returning complex types in AL Language

Returning complex types in AL Language

In Microsoft Dynamics 365 Business Central 2021 w1 (released in May 2021), a profound change was introduced to ways how we can design our applications Until this version, the only way to return complex data types (like records, codeunits, Lists etc.) was using the var...

read more
Import various file types with Interfaces

Import various file types with Interfaces

A few weeks ago, I described a solution for importing an Excel file to the Business Central using Excel Buffer in AL Language (see here). In today's article, we will look at how to build a more complex solution that can be used for file imports without the needs to...

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