Microsoft Dynamics 365 Blog

QR codes (abbreviated from Quick Response code) are appearing in many different places today, and they are found to be quick and efficient when it comes to working with mobile phones and other devices which can read them. QR Code is a multipurpose instrument and it can hold all sorts of different types of valuable information like your company’s or your salesperson’s contact details, sales invoice information, promotional codes, location information, checksums, amounts, web links etc., which you can read using a QR code reader to automate some of the routine manual processes, like typing in things manually. 

The QR code is a two-dimensional data-matrix which can be decoded very fast. The format is clearly defined and published as an ISO standard.

QR code

As the Windows Phone 7.5 update, code name “Mango”, rolls out to customers, it makes it even more relevant to use the QR codes, as you can now use your Windows phone camera to scan QR codes by bringing them into camera view. Bing will recognize QR codes and will help you save and use the information encoded in it.

In some countries, popularity of QR codes has grown so much, that their usage is now considered a national standard. Our team has recently released an update for the Mexican market, where we added QR codes to several major Microsoft Dynamics NAV documents. And we thought – why don’t we let everyone else enjoy this new cool feature?

The update is available for NAV 5.0 SP1, NAV 2009 SP1 and NAV 2009 R2 versions of the product.

URLs for Microsoft Dynamics NAV 2009 SP1 and R2:   

URLs for Microsoft Dynamics NAV 5.0 SP1 :

However, the only part you need from it is the MXElectronicInvoice.msi file included in the package. Note that the .msi file is exactly the same for both versions of NAV.

Here is what you have to do to get your data encoded into a QR code:

1. Run the installer to deploy the dll we shipped for this update. Among other things, the dll includes QRCodeProvider  and IBarCodeProvider classes which we can use.

2. Add a BLOB field which will be storing the QR Code image into the Sales Invoice Header table for example:

3. Remember to set the SubType property to Bitmap if you would like to use the QR code on pages:

4. You can now use the following code to generate a QR code image, which for demo purposes will be saved into a first found posted sales invoice (needless to say, you should be doing it on a test database 😉 ) In this example we will encode a contact card with some predefined details.

OBJECT Codeunit 50001 QR Code Mgt.
    Version List=QR Code;
            CompanyInfo@1170000004 : Record 2000000006;
            SalesInvoiceHeader@1170000003 : Record 112;
            TempBlob@1170000002 : Record 99008535;
            QRCodeInput@1170000000 : Text[1024];
            QRCodeFileName@1170000001 : Text[1024];
            // Save a QR code image into a file in a temporary folder
            QRCodeInput := CreateQRCodeInput(‘John,Doe’,’+555 1231231′,’john@doe.zzz’,’www.johndoe.zzz’);
            QRCodeFileName := GetQRCode(QRCodeInput);
            QRCodeFileName := MoveToMagicPath(QRCodeFileName); // To avoid confirmation dialogue on RTC

           // Load the image from file into the BLOB field
            IF SalesInvoiceHeader.FINDFIRST THEN BEGIN
              SalesInvoiceHeader.”QR Code” := TempBlob.Blob;

           // Erase the temporary file
              IF EXISTS(QRCodeFileName) THEN

      ThreeTierMgt@1170000001 : Codeunit 419;

    LOCAL PROCEDURE CreateQRCodeInput@1020046(Name@1020000 : Text[80];PhoneNo@1020002 : Text[80];EMail@1020003 : Text[80];URL@1170000000 : Text[80]) QRCodeInput : Text[1024];
      QRCodeInput :=
        ‘MECARD:’ +
        ‘N:’ + Name + ‘;’ +
        ‘TEL:’ + PhoneNo + ‘;’ +
        ‘EMAIL:’ + EMail + ‘;’ +
        ‘URL:’ + URL + ‘;’;

    LOCAL PROCEDURE GetQRCode@1020038(QRCodeInput@1020001 : Text[1024]) QRCodeFileName : Text[1024];
      IBarCodeProvider@1020000 : Automation “{89F54BC4-E6C9-44BA-8574-86568625BFF8} 1.0:{9FE38730-1A3C-4B84-A8C2-AFAC6A90E641}:’Microsoft Dynamics Nav MX Services’.IBarCodeProvider”;
      QRCodeFileName := IBarCodeProvider.GetBarCode(QRCodeInput);

    PROCEDURE GetBarCodeProvider@1020001(VAR IBarCodeProvider@1020000 : Automation “{89F54BC4-E6C9-44BA-8574-86568625BFF8} 1.0:{9FE38730-1A3C-4B84-A8C2-AFAC6A90E641}:’Microsoft Dynamics Nav MX Services’.IBarCodeProvider”);
      QRCodeProvider@1020002 : Automation “{89F54BC4-E6C9-44BA-8574-86568625BFF8} 1.0:{69FEA5E6-0A76-4555-B74B-F170956B0098}:’Microsoft Dynamics Nav MX Services’.QRCodeProvider”;
      IF ISCLEAR(QRCodeProvider) THEN
      IBarCodeProvider := QRCodeProvider;

    PROCEDURE MoveToMagicPath@1170000000(SourceFileName@1170000000 : Text[1024]) DestinationFileName : Text[1024];
      FileSystemObject@1170000001 : Automation “{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B} 1.0:{0D43FE01-F093-11CF-8940-00A0C9054228}:’Windows Script Host Object Model’.FileSystemObject”;
      DestinationFileName := ThreeTierMgt.ClientTempFileName(”,”);
      IF ISCLEAR(FileSystemObject) THEN


5. With the image saved in the BLOB field, it is now “business as usual” to add it to a report. You can see, for example, how company logo is added to the standard NAV document reports. NB. Don’t forget to run CALCFIELDS on the “QR Code” field before you display its content. 🙂

6. And finally – run the report to see the QR code which you or your customers can scan, for example, with your favorite  Windows 7.5 mobile phone:


These postings are provided “AS IS” with no warranties and confer no rights. You assume all risk for your use.


Best regards,

Microsoft Dynamics NAV ERM Team

Dmitry Chadayev, Program Manager

We're always looking for feedback and would like to hear from you. Please head to the Dynamics 365 Community to start a discussion, ask questions, and tell us what you think!