🚀 Generate Enhanced QR Codes in Business Central Using AL and QuickChart API
🚀 Generate Enhanced QR Codes in Business Central Using AL and QuickChart API
Introduction
QR codes have become a standard tool for sharing data quickly and efficiently—whether it's for product labeling, document tracking, or digital payments. Now, you can generate customized QR codes and barcodes directly within Microsoft Dynamics 365 Business Central using a simple action.
This feature allows users to choose the barcode type and size, embed the image into a record, and optionally download it—all with just a few clicks. It's an easy way to enhance records with scannable information, without leaving Business Central or needing external tools.
In this article, we'll walk through how this feature works and how it can be used in real business scenarios.
What This Feature Does?
The "Generate Enhanced QR Code" action gives users the ability to quickly create and manage barcodes within Business Central. Here's what it can do:
Supports Multiple Barcode Types
Choose from common formats like:
QR Code
Swiss QR Code
Aztec Code
Data Matrix
Telepen
Customizable Size
Users can select the size of the barcode image:
Small (150x150)
Medium (200x200)
Large (300x300)
Auto-Generated Barcode Text
The barcode is automatically created using a combination of the record's No. and Description fields.
Image Saved to the Record
Once generated, the QR code is saved into the record’s Picture field, replacing any existing image (with confirmation).
Optional Local Download
After generating the barcode, users are asked if they’d like to download a copy of the image to their device.
Validation Checks
The feature checks for missing data (e.g., Description) and confirms before overwriting existing images.
Business Scenarios Where This Shines
Warehouse & Inventory Teams can generate shelf or product labels.
Sales & Marketing can embed item QR codes into print catalogs.
Manufacturing Units can print barcodes for machine-readable logs.
Pharma and Food industries can improve traceability and compliance.
AL Code Behind the Feature
pageextension 50020 "ItemCardExt" extends "Item Card"
{
actions
{
addfirst(processing)
{
action(GenerateEnhancedQRCode)
{
ApplicationArea = All;
Caption = 'Generate Enhanced QR Code';
Image = CreateDocument;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
var
HttpClient: HttpClient;
HttpRequest: HttpRequestMessage;
HttpResponse: HttpResponseMessage;
InS: InStream;
QRCodeURL: Text;
FileName: Text;
CustomText: Text;
SizeOption: Integer;
BarcodeLink: Text;
Size: Text;
BarcodeTypes: Label 'QR Code, Swiss QR Code, Telepen, Aztec, Data Matrix';
BarcodeOptions: Integer;
SizeTypes: Label 'Small, Medium, Large';
OverwriteQuestion: Label 'A picture already exists. Replace it?';
DescriptionMissingErr: Label 'You must enter a description before generating a QR code.';
begin
// Check required description
if Rec.Description = '' then
Error(DescriptionMissingErr);
// Confirm overwrite if needed
if Rec.Picture.Count > 0 then
if not Confirm(OverwriteQuestion, false) then
exit;
SizeOption := StrMenu(SizeTypes);
case SizeOption of
1:
Size := '150';
2:
Size := '200';
3:
Size := '300';
else
exit;
end;
BarcodeOptions := StrMenu(BarcodeTypes);
case
BarcodeOptions of
1:
BarcodeLink := StrSubstNo('https://quickchart.io/barcode?type=' + 'qrcode' + '&text=%1&width=%2&height=%2&format=png',Rec."No." + '_' + Rec.Description, Size);
2:
BarcodeLink := StrSubstNo('https://quickchart.io/barcode?type=' + 'swissqrcode' + '&text=%1&width=%2&height=%2&format=png',Rec."No." + '_' + Rec.Description, Size);
3:
BarcodeLink := StrSubstNo('https://quickchart.io/barcode?type=' + 'telepen' + '&text=%1&width=%2&height=%2&format=png',Rec."No." + '_' + Rec.Description, Size);
4:
BarcodeLink := StrSubstNo('https://quickchart.io/barcode?type=' + 'azteccode' + '&text=%1&width=%2&height=%2&format=png',Rec."No." + '_' + Rec.Description, Size);
5:
BarcodeLink := StrSubstNo('https://quickchart.io/barcode?type=' + 'datamatrix' + '&text=%1&format=png',Rec."No." + '_' + Rec.Description);
end;
// Create filename and URL
FileName := Rec.Description + '_QRCode.png';
QRCodeURL := StrSubstNo(
'https://quickchart.io/barcode?type=qrcode&text=%1&width=%2&height=%2&format=png',
Rec."No." + '_' + Rec.Description, Size);
// Send HTTP request
HttpRequest.SetRequestUri(BarcodeLink);
HttpRequest.Method := 'GET';
if not HttpClient.Send(HttpRequest, HttpResponse) then
Error('Failed to connect to QR code service.');
if not HttpResponse.IsSuccessStatusCode then
Error('QR Code generation failed. Status: %1', HttpResponse.HttpStatusCode);
// Read the response as stream
HttpResponse.Content.ReadAs(InS);
// Save to record
Clear(Rec.Picture);
Rec.Picture.ImportStream(InS, FileName);
Rec.Modify(true);
// Download copy to local if user wants
if Confirm('Do you want to download the QR Code image locally?', false) then
DownloadFromStream(InS, '', '', '', FileName);
end;
}
}
}
}
Output:
Choose an image size (Small, Medium, Large).
Select a barcode type (QR, Swiss QR, Aztec, Data Matrix, Telepen).
Store the generated image in the Picture field of the item record.
Conclusion
This customization shows how a simple AL code extension can greatly boost efficiency in Microsoft Dynamics 365 Business Central. By enabling quick generation and embedding of QR codes and barcodes, you eliminate manual steps and streamline processes across departments—from inventory to sales and beyond.
With support for multiple barcode types, customizable sizes, and built-in download and validation prompts, this feature brings powerful functionality right into the user's workflow—no external tools needed.
Whether you're in warehousing, retail, manufacturing, or pharma, this tool helps standardize product labeling and enhances traceability with just a few clicks.
💡 Looking ahead? You can extend this further by including additional record fields, customizing encoding logic, or supporting more document types like purchase orders or invoices.
Business Central just got a little smarter—one QR code at a time.