Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

QR Code vs Invoice printout

(2) ShareShare
ReportReport
Posted on by

 

There can be many blog posts about how to use 2D barcodes (QR codes, mainly) within Dynamics 365 Business Central but not that many are using an Invoice to demo them.

I will try to have this gap fixed at my style. 

First things first.

Report (aka clone the report) or Report Extensions?

Report Extensions have the (big) advantages of

  1. Not cloning the entire report hence YOU do not have to maintain that entirely
  2. Not cloning the entire report hence a smaller AL file
  3. Not cloning the entire report hence… whatever else related to not cloning the entire report

If you have to simply printout one or more field header values (e.g. the invoice No. – e.g. Sales Header No. -) then a Report Extension is the right way to go. Silent, swift (and deadly), like the US Marines motto.

Few lines of code and you do not have to maintain the whole report, keep extension file smaller, etc. Simple as 1,2,3.

When it comes to let’s say print out

  1. Document No.
  2. Printing Date
  3. All Total Amounts Values
  4. Whatever else that is not a field bounded to a table (e.g. a global or local report variable)

Then it gets just a bit more complicated and it falls back to Amleth’s dilemma: to clone or not to clone?

Writing universal code, would lead in trying to use Report Extension as much as possible BUT if developing a Report Extension would require to re-calculate all totals only for the sake of having these printed in QR Code then this is a no go. This might have performance implications.

So that, to go straight to the point, the more data are needed to be stored in QR Code that are not directly bounded to a table data item, the higher are the chances to clone the original report and add QR Code there.

How to achieve that? (Considering 19.1 and W1 Localized version)

 

  1. Clone Report 1306 Standard Sales Invoice and its own RDL and Word Layout and renumber it like e.g. the following

pastedimage1640275433425v2.png

  1. Create 2 global variables: BarcodeString and EncodedTotals as Text.

 pastedimage1640275465703v3.png

 

  1. In Header data item, remember to initialize them as per the following

 pastedimage1640275500783v4.png

 

  1. In ReportTotalsLine data item add the following OnAfterGetRecord trigger and its code

 pastedimage1640275544328v5.png

 

  1. In Totals data item add the 2 Columns needed to populate the dataset

 pastedimage1640275574732v6.png

and the following OnAfterGetRecord trigger and its code to generate the Barcode string and its equivalent encoded value

 pastedimage1640275605258v7.png

 

  1. And that is all the code needed in AL. Now, let’s add 2 plain text item in the Word Layout like the following.

NOTE: Be absolutely sure that EncodedTotals has IDAutomation2D fonts (exactly as it is written)

 pastedimage1640275641017v8.png

(NOTE: BarcodeString has been jus added to showcase what is encoded in the QR).

 

If you deploy this extension then you can run this directly using Tell Me feature or you could also think to add a simple codeunit that subscribe to OnAfterSubstituteReport event in ReportManagement codeunit as written officially in Substituting Reports - Business Central | Microsoft Docs.

 

Below a screenshot of the report output. Try out with your device to scan it.

pastedimage1640275699249v9.png

  • THE Italian Profile Picture
    on at
    RE: QR Code vs Invoice printout

    This might be due to one or more of the following

    a. You are not using a W1 report but a localized one

    b. You are not using exactly minor version 19.1

    In any case the solution is super easy: remove all directives.

  • Tim Profile Picture
    100 on at
    RE: QR Code vs Invoice printout

    I have followed the process you have highlighted above. Though am getting an error of [tag:endif] directive expected. Where have you ended the directive in step number 3?pastedimage1665402735815v1.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 1,063

#2
YUN ZHU Profile Picture

YUN ZHU 1,002 Super User 2025 Season 1

#3
Mansi Soni Profile Picture

Mansi Soni 780

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans