Wednesday, June 8, 2016

Add a QR Code to a Dynamics NAV 2015/2016 in Report Header

Add a QR Code to a Dynamics NAV 2015/2016 in Report Header
Hi All,
This article will demonstrate how to add a QR Code to a NAV 2016.

For this example I have made a copy of the Order Confirmation Report (ID 205) and save it as QR Order Confirmation (ID 50023).

I have redirected the Company Information Picture field in the report to point to a new BLOB field in the Sales Header Table (ID 36) called “QR Code”.

Note: If you need QR Code Generator Solution Objects, Then ping me, It's free of cost available for learning purpose.
Step 1:  Open Sales Header Table [ID 36] and Add fields [see the bellow screenshot].


After Added fields add some code in OnInsert trigger [see the bellow screenshot].



Step 2:  Create a new codeunit for ”QR Code” functionalities.
                In my case i seted the property Table No with value  ”Sales Header”,
        [ See the bellow screenshot].





In this Codeunit i wrote  four functions for relating QR Code, i.e.
1.       CreateQRCodeInput
2.       GetQRCode
3.       GetBarCodeProvider
4.       MoveToMagicPath

 See the bellow screenshot of full ”QR  Code Management” Codeunit C/AL Code.





Step 3:  Create a Report, In my case i made Save as of Report ID 205 ” Order Confirmation”.
                In that i made some changes:
1.       QRCodeManagement varible of Codeunit of 50010 ” QR Code Management” that earlier created.
2.       Added Data item fields for getting the QR Code Image from Sales Header [See the screenshot].





3.       Add couple of lines in ”Sales Header” OnAfterGetRecord Trigger, to run the ”QR Code Management” Codeunit  and get the QR code image from ”Sales Header” Table [see the bellow screenshot].





Step 4:  Open Report Layout design and create a Image control in Report Header, In my case i used earlier company logo field and populate with new QR fields that i created in Report dataitem [see the bellow screenshot].




After changes save report and exit.

Step 5:  Run the report that you created with require filters [see the bellow screenshot].








21 comments:

  1. Great article, after reading this feeling proud.

    ReplyDelete
  2. hiii,
    i have write the same code ,my report is working fine but QR Code is not showing in header only showing cross mark.

    ReplyDelete
    Replies
    1. Can you please share your report at mcabinesh@live.com,so i can check.

      Delete
    2. Hii,
      I have a the same problem, how did you resolve it?

      Delete
  3. Hi,
    I am not getting this dotnet variable(IBarcodeProvider) in NAV 2016 and getting in Navision 2013. I need it in nav 2016. Please suggest the way. Thanks in advance.

    ReplyDelete
  4. In Data Type Choose DotNet and then click on SubType
    Then Click on Assembly, then click on Server tab and choose
    Microsoft.Dynamics.Nav.MX
    After clicking OK, choose Microsoft.Dynamics.Nav.MX.BarcodeProviders.IBarcodeProvider

    ReplyDelete
  5. I have an error can't serialize an instance of the following .Net framework object: assembly Microsoft.Dynamics.Nav.Mx...
    Microsoft.Dynamics.Nav.Mx.BarCodeProviders.QRCodeProvider

    ReplyDelete
  6. Hi,
    You get this error if you assign a server-side object to a client-side object and vice versa. So check, if all variables have set property RunOnClient to true.
    I'm guessing that you didn't set RunOnClient property to Yes for local variable QRCodeProvider in function GetBarCodeProvider(). Both IBarCodeProvider and QRCodeProvider shoud have the same property.

    ReplyDelete
  7. Really I enjoy your site with effective and useful information on
    dynamics nav support

    ReplyDelete
  8. A call to System.__ComObject.MoveFile failed with this message: Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENIED) Iam getting this error while running the report

    ReplyDelete
  9. Thank you, Can you please send me the example object of QR Code management?

    ReplyDelete
  10. HI I HAVE TRIED THE CODE BUT FACING THE BELOW ERROR

    Microsoft Dynamics NAV
    ---------------------------

    A call to Microsoft.Dynamics.Nav.MX.BarcodeProviders.IBarcodeProvider.GetBarcode failed with this message: Cannot create barcode.
    Parameter name: barcodeInput
    ---------------------------
    OK
    ---------------------------

    ReplyDelete
  11. It's very nice of you to share your knowledge through posts. I love to read stories about your experiences. They're very useful and interesting. I am excited to read the next posts. I'm so grateful for all that you've done. Keep plugging. Many viewers like me fancy your writing. Thank you for sharing precious information with us. Best Upc Barcodes For Sale service provider.

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. Kindly help me to Add QR Code in POSPrint Utility

    ReplyDelete
  14. hello Binesh, can you provide the qr code provider objects please ?
    this is my email, hamed.elarnaout@gmail.com

    ReplyDelete
  15. Could you please send me the QR Code Objects.

    ReplyDelete
  16. Could you please send me the QR Code Objects. My e-mail address is emackietx@gmail.com

    ReplyDelete
  17. Hi - can you please share the QR Code Generator Solution Objects with me? mariam.it.1900@gmail.com

    Thanks in advance!

    ReplyDelete
  18. how to do it in Business Central Cloud (without using any dotnet variable).

    ReplyDelete
  19. Thanks For Sharing, We make the technology much simpler and Grow your business with our QR Rocket.
    Visit https://qrrocket.com/!

    ReplyDelete

Popular Posts