Wednesday, May 4, 2022

Generate QR Code in Business Central (On-Prime) Version

Hello Friends,

Using QR Generator codeunit in Indian Localization we can generate the QR Code in BC on-Prime version.

Sample Code to Generate QR Code Blob Image File.

report 67467 ItemBarCode
{
    UsageCategory = Administration;
    ApplicationArea = All;
    DefaultLayout = RDLC;
    Caption = 'Item Barcodes (BC On-Prime)';
    RDLCLayout = 'ItemBarcodes.rdl';
    dataset
    {
        dataitem(Item; Item)
        {
            DataItemTableView = sorting("No.");
            RequestFilterFields = "No.";
            RequestFilterHeading = 'Items';
            column(No_; "No.")
            {
            }
            column(Description; Description)
            {
            }

            column(QR_BLOB; ComInf_gRecTmp.Picture)
            {
            }
            trigger OnAfterGetRecord()
            var
                OS_iOS: OutStream;
                IS_iIN: InStream;
                TempBlob: Codeunit "Temp Blob";
                QRBase64String: Text;
                QRGenerator: Codeunit "QR Generator";
            begin
                QRBase64String := Item."No." + '|' + Item."Description";

                TempBlob.CreateInStream(IS_iIN);
                QRGenerator.GenerateQRCodeImage(QRBase64String, TempBlob);
                ComInf_gRecTmp.Reset();
                ComInf_gRecTmp.DeleteAll();

                ComInf_gRecTmp.Init();
                ComInf_gRecTmp.Picture.CreateOutStream(OS_iOS);
                COPYSTREAM(OS_iOS, IS_iIN);
                ComInf_gRecTmp.Insert(TRUE);
                ComInf_gRecTmp.CalcFields(Picture);
            end;
        }
    }

    var
        ComInf_gRecTmp: Record "Company Information" temporary;
}

RDLC Layout File Design:


Sample Output in BC On-Prime:






Note: you need to add depedancy "QR Generator" in indian localization BC Version

    {
      "id": "7106d701-c601-4a5f-97c2-b8b323ae2c18",
      "publisher": "Microsoft",
      "name": "QR Generator",
      "version": "19.0.0.0"
    }

Thank you for reading.
I hope this help someone
Keep Sharing...Keep Growing...


5 comments:

  1. สูตรสล็อต Pg slot แหล่งทำเงินสล็อตยอดนิยมปี 2021 เล่นง่าย ได้เงินจริง มีระบบฝากถอนเงินด้วยระบบออโต้ที่รวดเร็ว

    ReplyDelete
  2. where can I find the QR Generator codeunit? Thank in advance

    ReplyDelete
    Replies
    1. it is part of Indian localization QR Code generator extension

      Delete
  3. Thanks for sharing it helps to learn..

    ReplyDelete