Advanced Barcode Generation

Advanced Barcode Generation

You are here:

The main purpose of this extension is to provide a tool to developers that have a requirement to add barcodes to their reports or their client’s reports.

Retrieve Barcode Generation Symbols

Before starting, ensure Barcode Generator is installed (see Install and Uninstall Barcode Generator). Once Barcode Generator is installed, you can download the symbols and use the generation functions. Complete the following to obtain the symbols:

  1. Create an AL project in Visual Studio Code.
  2. Set the launch.json file in the project to the Microsoft Dynamics 365 Business Central sandbox.

{

    “version”: “0.2.0”,

    “configurations”: [

        {

            “type”: “al”,

            “request”: “launch”,

            “name”: “Microsoft cloud sandbox”,

        }

    ]

}

     3. Include the Barcode Generation extension as a dependency in the dependencies portion of the app.json file.

“dependencies”: [

    {

      “appId”: “62080fe0-d57f-4d4c-aed1-ac539db3a244”,

      “publisher”: “Insight Works”,

      “name”: “Barcode Generator”,

      “version”: “1.3.7723.3”

    }

  ]

  1. Use the search window to select AL: Download Symbols while in the same project (downloads the sandbox’s symbol file into the .alpackages project folder).

You now have access to the Barcode Generation procedures. These may be used in your reports and can be deployed as a per tenant extension to your or your client’s Microsoft Dynamics 365 Business Central environment.

Barcode Generation Functions

The procedures are contained in Codeunit 23044800 – IWX Library – Barcode Gen.

GenerateMatrixBarcode

This function generates a 2D barcode in a Data Matrix format. The following parameters are in order of the function signature.

Parameter

Type

Input

Comment

precBarcode

var Record “IWX Barcode” temporary

temporary “IWX Barcode” variable

When the function is successful, “IWX Barcode”.Image populates with the barcode image.  

ptxtBarcodeContent

Text[1024]

barcode data

The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned is unique to your needs.

piBarcodeImageSize

Integer

desired symbol size

Defines the symbol sizes, it can vary from 10×10 to 144×144 (int 1 = 10×10). You can use the Barcode Generator’s enumerator 23044803 IWX Barcode Image Size.

piBarcodeMultiplier

Integer

desired barcode resolution

The minimum value is 8, which translates to a size of 2px per dot. A multiplier of 16 equals 4px per dot.

GenerateMatrixBarcode override

This function generates a 2D barcode in a Data Matrix format. The following parameters are in order of the function signature.

Parameter

Type

Input

Comment

pcuTempBlob

var Codeunit “Temp Blob””

Codeunit “Temp Blob”” variable

When the function is successful, the instance of the codeunit variable contains the barcode image in the outstream.  

ptxtBarcodeContent

Text[1024]

barcode data

The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned is unique to your needs.

piBarcodeImageSize

Integer

desired symbol size

Defines the symbol sizes, it can vary from 10×10 to 144×144 (int 1 = 10×10). You can use the Barcode Generator’s enumerator 23044803 IWX Barcode Image Size.

piBarcodeMultiplier

Integer

desired barcode resolution

Defines the dot size with the minimum value of 8, which translates to a dot size of 2px2. A multiplier of 16 translates to 4px2 per dot.

GenerateQRBarcode

This function generates a 2D barcode in a QR format. The following parameters are in order of the function signature.

Parameter

Type

Input

Comment

precBarcode

var Record “IWX Barcode” temporary

temporary “IWX Barcode” variable

When the function is successful, “IWX Barcode”.Image populates with the barcode image.  

ptxtBarcodeContent

Text[1024]

barcode data

The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned is unique to your needs.

piBarcodeDotSize

Integer

desired barcode resolution

Defines the dot size with the minimum value of 2, which translates to a dot size of 2px2. A value of 4 translates to a dot size 4px2.

GenerateQRBarcode override

This function generates a 2D barcode in a QR format. The following parameters are in order of the function signature.

Parameter

Type

Input

Comment

pcuTempBlob

var Codeunit “Temp Blob””

Codeunit “Temp Blob”” variable

When the function is successful, the instance of the codeunit variable contains the barcode image in the outstream.  

ptxtBarcodeContent

Text[1024]

barcode data

The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned is unique to your needs.

piBarcodeDotSize

Integer

desired barcode resolution

Defines the dot size with the minimum value of 2, which translates to a dot size of 2px2. A value of 4 translates to a dot size 4px2.

Generate39Barcode

This function generates a 1D barcode in the Code39 format. The following parameters are in order of the function signature.

Parameter Type Input Comment
precBarcode var Record “IWX Barcode” temporary temporary “IWX Barcode” variable When the function is successful “IWX Barcode”.Image populates with the barcode image.
ptxtBarcodeContent Text[1024] barcode data The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned will be unique to your needs.
piWidth Integer desired width in pixels  
piHeight Integer desired height in pixels  

Generate39Barcode override

This function generates a 1D barcode in the Code39 format. The following parameters are in order of the function signature.

Parameter

Type

Input

Comment

pcuTempBlob

var Codeunit “Temp Blob””

Codeunit “Temp Blob”” variable

When the function is successful, the instance of the codeunit variable contains the barcode image in the outstream.  

ptxtBarcodeContent

Text[1024]

barcode data

The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned is unique to your needs.

piWidth

Integer

desired width in pixels

 

piHeight

Integer

desired height in pixels

 

Generate128Barcode

This function generates a 1D barcode in the Code128 format. The following parameters are in order of the function signature.

Parameter

Type

Input

Comment

precBarcode

var Record “IWX Barcode” temporary

temporary “IWX Barcode” variable

When the function is successful, “IWX Barcode”.Image is populated with the barcode image.  

ptxtBarcode

Text[1024]

barcode data

The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned is unique to your needs.

piWidth

Integer

desired width in pixels

 

piHeight

Integer

desired height in pixels

 

Generate128Barcode override

This function generates a 1D barcode in the Code128 format. The following parameters are in order of the function signature.

Parameter

Type

Input

Comment

pcuTempBlob

var Codeunit “Temp Blob””

Codeunit “Temp Blob”” variable

When the function is successful, the instance of the codeunit variable contains the barcode image in the outstream.  

ptxtBarcode

Text[1024]

barcode data

The barcode image is created with the information contained in this string. The format of that string and how it is interpreted when the barcode is scanned is unique to your needs.

piWidth

Integer

desired width in pixels

 

piHeight

Integer

desired height in pixels

 

Barcode Generation Helper Functions

The procedures are contained in Codeunit 23044800 – IWX Library – Barcode Gen.

GetBarcodeFormat

This function is used for leveraging user-defined barcode document prefixes in the Barcode Setup page. The following parameters are in order of the function signature.

Parameter

Type

Input

Comment

ptxtCode

var Codeunit “Temp Blob””

Codeunit “Temp Blob”” variable

The raw barcode content.  

peDocument

Enum “IWX Documents”

An enumerator from the Enum 23044801 – IWX Documents.

The barcode content is prefixed with the document’s prefix value set in the Barcode Setup page.

Return Value

Type

Comment

Barcode Content

Text[1024]

The raw barcode content prefixed.

GetBarcodeFormat override

This function is used for activities barcodes, leveraging user-defined barcode document prefixes and activity suffixes in the Barcode Setup page. The following parameters are in order of the function signature.

Parameter

Type

Input

Comment

ptxtCode

var Codeunit “Temp Blob””

Codeunit “Temp Blob”” variable

The raw barcode content.  

peDocument

Enum “IWX Documents”

An enumerator from the Enum 23044801 – IWX Documents.

The barcode content is prefixed with the document’s prefix value set in the Barcode Setup page.

peActivity

Enum “IWX Activities”

An enumerator from the Enum 23044800 – IWX Activities

The barcode content is suffixed with the warehouse activities’ suffix value set in the Barcode Setup page.

Return Value

Type

Comment

Barcode Content

Text[1024]

The raw barcode content prefixed and suffixed.  

Use Barcode Generation in a Report

These functions return an IWX Barcode object that has the barcode image set in the Image field. That Image field may be used in a DataItem column, which shows up where referenced in the report layout.

Report Object

In the report object you would set the value under the relevant DataItem. In the example below “100” is replaced with the string that represents the data you would like to have included in the barcode.

dataitem(Loop; “Integer”)

{

    DataItemTableView = SORTING (Number);

    column(barcodeImage; Barcode.Image)

    {

    }

    trigger OnPreDataItem();

    begin

        SETRANGE(Number, 1, 1);

    end;

    trigger OnAfterGetRecord();

          BarcodeGeneration: Codeunit “IWX Library – Barcode Gen”;

    begin

          BarcodeGeneration.Generate39Barcode(Barcode, ‘100’,

550, 220);               

    end;

}

var

         Barcode: Record “IWX Barcode” temporary;

Report Layout

Include this column in the report layout by adding an image element. Based on the above example, the properties would look like the following:

field: =First(Fields! barcodeImage.Value, “DataSet_Result”)

Source: Database

MIME: image/bmp

Display: Fit proportional

Was this article helpful?
2.5 out Of 5 Stars

10 ratings

5 Stars 10%
4 Stars 30%
3 Stars 10%
2 Stars 0%
1 Stars 50%
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
Need help?

2 Comments

  1. Drew Kipfer
    Drew Kipfer December 21, 2020 at 12:54 pm

    Will this documentation be updated or appended with the latest changes necessary due to the TempBlob being marked for removal? Thanks!

    • Travis Plett
      Travis Plett December 22, 2020 at 2:21 pm

      As of Barcode Generator version 1.3.7377.1 the precBarcode type is now:
      var Record “IWX Barcode” temporary
      And input is now:
      temporary “IWX Barcode” variable

      All other setting remain the same.

Leave A Comment

Go to Top