Hi, Readers.
The barcode functionality lets you convert an alphanumeric value in a report dataset into a barcode on a generated report. The functionality is provided by the Barcode module of the System Application. The module includes the objects and tools that you need to add barcodes to reports. More details:


This is a standard function provided by Microsoft. We can simply add it in the extension using AL. However, if the customer requires a QR code in a special format, such as a special size, background color, etc., the standard cannot do it. For example,

At this time we can use some external services/APIs. Here is the API I used for this test:
QR Code API: QuickChart supports QR code generation. Generate a QR code like this: https://quickchart.io/qr?text=Here’s my text
QR code parameters: Build your customized QR code using the following query parameters. You may also use the web-based QR code builder.
Parameter Name | Description | Required? | Default value |
---|---|---|---|
text | Content of the QR code (can be a URL or any other string) | Yes | |
format | Format of QR code, either png, svg, or base64 | png | |
margin | Whitespace around QR image | 4 | |
size | Width and height dimension of the image | 150 | |
dark | Hex color code of “dark” QR grid cells | 000000 (black) | |
light | Hex color code of “light” QR grid cells | ffffff (white) | |
ecLevel | Error correction level (L, M, Q, H) | M (H if center image is present) | |
centerImageUrl | URL of image to show in the center. Must be URL-encoded. | ||
centerImageSizeRatio | How much space to take up, between 0.0 and 1.0 | 0.3 | |
centerImageWidth | Width of center image in pixels | ||
centerImageHeight | Height of center image in pixels | ||
caption | Caption text to display below the QR code. | ||
captionFontFamily | Font family of the caption text | ‘sans-serif’ | |
captionFontSize | Font size of the caption text in pixels. | 10 | |
captionFontColor | Color caption text, color names or hex code. | black |
Here’s the same code as above but URL encoded with slimmer margins, more error protection, colors, and in SVG format: https://quickchart.io/qr?text=Here’s%20my%20text&dark=f00&light=0ff&ecLevel=Q&format=svg

Let’s look at a simple example of utilizing this API from AL: Generate a QR Code from the Item Number and Item Description, and then save the QR Code in the Item Picture. (Of course, you can also create a new media field or blob field to save the QR Code)




In addition, we can also add an image to the QR Code, which is also impossible in the standard. (Only the URL is different)
BarcodeAPIURL := 'https://quickchart.io/qr?text=' + Rec."No." + '_' + Rec.Description + '¢erImageUrl=https://yzhums.com/wp-content/uploads/2025/05/Snipaste_2025-05-19_14-42-11.png';

And we can also add some instructions below the QR Code.
BarcodeAPIURL := 'https://quickchart.io/qr?text=' + Rec."No." + '_' + Rec.Description + '&caption=TextBelowQr&captionFontFamily=mono&captionFontSize=20'; //Text below QR code

Source code: Github (Please note that the source code is for reference only, you can improve it according to your own needs)
pageextension 50112 ItemCardExt extends "Item Card"
{
actions
{
addfirst(processing)
{
action(GenerateQRCode)
{
ApplicationArea = All;
Caption = 'Generate QR Code';
Image = CreateDocument;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
var
BarcodeAPIURL: Text;
Client: HttpClient;
HttpResponseMsg: HttpResponseMessage;
HttpRequestMsg: HttpRequestMessage;
InS: InStream;
OverrideImageQst: Label 'The existing picture will be replaced. Do you want to continue?';
MustSpecifyDescriptionErr: Label 'You must add a description to the item before you can import a picture.';
FileName: Text;
begin
if Rec.Description = '' then
Error(MustSpecifyDescriptionErr);
if Rec.Picture.Count > 0 then
if not Confirm(OverrideImageQst) then
Error('');
FileName := Rec.Description + '.png';
//BarcodeAPIURL := 'https://quickchart.io/qr?text=' + Rec."No." + '_' + Rec.Description + '&dark=f00&light=0ff&ecLevel=Q&format=png';// Here's the same code as above but URL encoded with slimmer margins, more error protection, colors, and in png format
BarcodeAPIURL := 'https://quickchart.io/qr?text=' + Rec."No." + '_' + Rec.Description + '¢erImageUrl=https://yzhums.com/wp-content/uploads/2025/05/Snipaste_2025-05-19_14-42-11.png';// Add an images in QR codes
//BarcodeAPIURL := 'https://quickchart.io/qr?text=' + Rec."No." + '_' + Rec.Description + '&caption=TextBelowQr&captionFontFamily=mono&captionFontSize=20'; //Text below QR code
HttpRequestMsg.SetRequestUri(BarcodeAPIURL);
if Client.Send(HttpRequestMsg, HttpResponseMsg) then begin
if HttpResponseMsg.IsSuccessStatusCode() then begin
HttpResponseMsg.Content.ReadAs(InS);
Clear(Rec.Picture);
Rec.Picture.ImportStream(InS, FileName);
Rec.Modify(true);
end;
end else
Error('Failed to send request to the API.');
end;
}
}
}
}
Of course, we can also generate other types of barcodes through external services/APIs.
Barcode API: https://quickchart.io/barcode?type=datamatrix&text=foo
Supported Parameters:
Parameter | Required | Description | Options |
---|---|---|---|
type | Yes | Specifies the type of barcode to generate (see list below). | |
text | Yes | The data or text you want to encode in the barcode. | |
width | No | Desired width of the barcode in pixels. | |
height | No | Desired height of the barcode in pixels. | |
scale | No | A scaling factor for the barcode, affecting both width and height. | |
includeText | No | If set, includes human-readable text (if supported by the barcode type). | true , false |
rotate | No | Controls the rotation of the barcode. | N (Normal), R (Right), L (Left), I (Inverted) |
Supported Barcode Types: Please note that some barcodes have limitations such as length or only support numbers. You can test it by url first, for example, https://quickchart.io/barcode?type=datamatrix&text=Custom%20Size&width=300&height=300
Barcode Type | Description |
---|---|
auspost | AusPost 4 State Customer Code |
azteccode | Aztec Code |
azteccodecompact | Compact Aztec Code |
aztecrune | Aztec Runes |
bc412 | BC412 |
channelcode | Channel Code |
codablockf | Codablock F |
code11 | Code 11 |
code128 | Code 128 |
code16k | Code 16K |
code2of5 | Code 25 |
code32 | Italian Pharmacode |
code39 | Code 39 |
code39ext | Code 39 Extended |
code49 | Code 49 |
code93 | Code 93 |
code93ext | Code 93 Extended |
codeone | Code One |
coop2of5 | COOP 2 of 5 |
daft | Custom 4 state symbology |
databarexpanded | GS1 DataBar Expanded |
databarexpandedcomposite | GS1 DataBar Expanded Composite |
databarexpandedstacked | GS1 DataBar Expanded Stacked |
databarexpandedstackedcomposite | GS1 DataBar Expanded Stacked Composite |
databarlimited | GS1 DataBar Limited |
databarlimitedcomposite | GS1 DataBar Limited Composite |
databaromni | GS1 DataBar Omnidirectional |
databaromnicomposite | GS1 DataBar Omnidirectional Composite |
databarstacked | GS1 DataBar Stacked |
databarstackedcomposite | GS1 DataBar Stacked Composite |
databarstackedomni | GS1 DataBar Stacked Omnidirectional |
databarstackedomnicomposite | GS1 DataBar Stacked Omnidirectional Composite |
databartruncated | GS1 DataBar Truncated |
databartruncatedcomposite | GS1 DataBar Truncated Composite |
datalogic2of5 | Datalogic 2 of 5 |
datamatrix | Data Matrix |
datamatrixrectangular | Data Matrix Rectangular |
datamatrixrectangularextension | Data Matrix Rectangular Extension |
dotcode | DotCode |
ean13 | EAN-13 |
ean13composite | EAN-13 Composite |
ean14 | GS1-14 |
ean2 | EAN-2 (2 digit addon) |
ean5 | EAN-5 (5 digit addon) |
ean8 | EAN-8 |
ean8composite | EAN-8 Composite |
flattermarken | Flattermarken |
gs1-128 | GS1-128 |
gs1-128composite | GS1-128 Composite |
gs1-cc | GS1 Composite 2D Component |
gs1datamatrix | GS1 Data Matrix |
gs1datamatrixrectangular | GS1 Data Matrix Rectangular |
gs1dldatamatrix | GS1 Digital Link Data Matrix |
gs1dlqrcode | GS1 Digital Link QR Code |
gs1dotcode | GS1 DotCode |
gs1northamericancoupon | GS1 North American Coupon |
gs1qrcode | GS1 QR Code |
hanxin | Han Xin Code |
hibcazteccode | HIBC Aztec Code |
hibccodablockf | HIBC Codablock F |
hibccode128 | HIBC Code 128 |
hibccode39 | HIBC Code 39 |
hibcdatamatrix | HIBC Data Matrix |
hibcdatamatrixrectangular | HIBC Data Matrix Rectangular |
hibcmicropdf417 | HIBC MicroPDF417 |
hibcpdf417 | HIBC PDF417 |
hibcqrcode | HIBC QR Code |
iata2of5 | IATA 2 of 5 |
identcode | Deutsche Post Identcode |
industrial2of5 | Industrial 2 of 5 |
interleaved2of5 | Interleaved 2 of 5 (ITF) |
isbn | ISBN |
ismn | ISMN |
issn | ISSN |
itf14 | ITF-14 |
japanpost | Japan Post 4 State Customer Code |
kix | Royal Dutch TPG Post KIX |
leitcode | Deutsche Post Leitcode |
mailmark | Royal Mail Mailmark |
mands | Marks & Spencer |
matrix2of5 | Matrix 2 of 5 |
maxicode | MaxiCode |
micropdf417 | MicroPDF417 |
microqrcode | Micro QR Code |
msi | MSI Modified Plessey |
onecode | USPS Intelligent Mail |
pdf417 | PDF417 |
pdf417compact | Compact PDF417 |
pharmacode | Pharmaceutical Binary Code |
pharmacode2 | Two-track Pharmacode |
planet | USPS PLANET |
plessey | Plessey UK |
posicode | PosiCode |
postnet | USPS POSTNET |
pzn | Pharmazentralnummer (PZN) |
qrcode | QR Code |
rationalizedCodabar | Codabar |
raw | Custom 1D symbology |
rectangularmicroqrcode | Rectangular Micro QR Code |
royalmail | Royal Mail 4 State Customer Code |
sscc18 | SSCC-18 |
swissqrcode | Swiss QR Code |
symbol | Miscellaneous symbols |
telepen | Telepen |
telepennumeric | Telepen Numeric |
ultracode | Ultracode |
upca | UPC-A |
upcacomposite | UPC-A Composite |
upce | UPC-E |
upcecomposite | UPC-E Composite |
Let’s look at another simple example, users can select one of five barcode types (‘QR Code, Data Matrix, Aztec, Telepen, Swiss QR Code’) and save it in the item picture.


Test video:
Source code: Github (Please note that the source code is for reference only, you can improve it according to your own needs)
pageextension 50112 ItemCardExt extends "Item Card"
{
actions
{
addfirst(processing)
{
action(GenerateQRCode)
{
ApplicationArea = All;
Caption = 'Generate QR Code';
Image = CreateDocument;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
var
BarcodeAPIURL: Text;
Client: HttpClient;
HttpResponseMsg: HttpResponseMessage;
HttpRequestMsg: HttpRequestMessage;
InS: InStream;
OverrideImageQst: Label 'The existing picture will be replaced. Do you want to continue?';
MustSpecifyDescriptionErr: Label 'You must add a description to the item before you can import a picture.';
FileName: Text;
BarcodeTypes: Label 'QR Code, Data Matrix, Aztec, Telepen, Swiss QR Code';
Selection: Integer;
begin
if Rec.Description = '' then
Error(MustSpecifyDescriptionErr);
if Rec.Picture.Count > 0 then
if not Confirm(OverrideImageQst) then
Error('');
FileName := Rec.Description + '.png';
Selection := StrMenu(BarcodeTypes);
case
Selection of
1:
BarcodeAPIURL := 'https://quickchart.io/barcode?type=' + 'qrcode' + '&text=' + Rec."No." + '_' + Rec.Description + '&width=200&height=200&format=png';
2:
BarcodeAPIURL := 'https://quickchart.io/barcode?type=' + 'datamatrix' + '&text=' + Rec."No." + '_' + Rec.Description + '&width=200&height=200&format=png';
3:
BarcodeAPIURL := 'https://quickchart.io/barcode?type=' + 'azteccode' + '&text=' + Rec."No." + '_' + Rec.Description + '&width=200&height=200&format=png';
4:
BarcodeAPIURL := 'https://quickchart.io/barcode?type=' + 'telepen' + '&text=' + Rec."No." + '_' + Rec.Description + '&width=200&height=200&format=png';
5:
BarcodeAPIURL := 'https://quickchart.io/barcode?type=' + 'swissqrcode' + '&text=' + Rec."No." + '_' + Rec.Description + '&format=png';
end;
HttpRequestMsg.SetRequestUri(BarcodeAPIURL);
if Client.Send(HttpRequestMsg, HttpResponseMsg) then begin
if HttpResponseMsg.IsSuccessStatusCode() then begin
HttpResponseMsg.Content.ReadAs(InS);
Clear(Rec.Picture);
Rec.Picture.ImportStream(InS, FileName);
Rec.Modify(true);
end;
end else
Error('Failed to send request to the API.');
end;
}
}
}
}
Very simple. You can also add a QR code to a report using the following methods.
- Dynamics 365 Business Central: How to add Media or MediaSet data type (Pictures) to a report
- How to generate QR code for Dynamics 365 Business Central Page URL (For example, embed the customer card URL in QR code)
Also, please note that some of these external services are not completely free, and you need to pay attention to the instructions on these websites. For example, QuickChart Pricing

You can also try other external services, such as the two below. If your country has better services, you can use them, not limited to those mentioned in this post. But please note that the structure and keywords of the URL may be different, the method is the same. Give it a try!!!😁
- https://orcascan.com/guides/free-barcode-image-api-0e4a4fa6
- https://barcode.tec-it.com/en/Code11?data=0123-4567
END
Hope this will help.
Thanks for reading.
ZHU
コメント