Create QR Code and print on SSRS report in Microsoft Dynamics AX 2012

If you are working with QR code and need to print it on SSRS report in Microsoft Dynamics AX 2012 then the below code will help you to achieve it in quite simple way.

Add a field to your temp table of type Container.

In your SSRS report place image and set Source Database, Your new container field and MIME type image/bmp. AssetBarCodeDP -- processReport()

public void processReport() { AssetTable assetTable; QueryRun queryRun; Filename filename; FileIOPermission perm = null; AssetBarCodeContract contract;

    contract = this.parmDataContract() as AssetBarCodeContract;

    barcodeSetup = BarcodeSetup::find(contract.parmBarCodeSetUpId());
    barcode = barcodeSetup.barcode();
    queryRun = new QueryRun(this.parmQuery());

    qrCode = new Microsoft.Dynamics.QRCode.Encoder();
    binData = new BinData();


    while (queryRun.next())
    {
        assetTable = queryRun.get(tableNum(AssetTable)) as AssetTable;
        assetBarCodeTmp.AssetId = assetTable.AssetId;
        assetBarCodeTmp.AssetName = assetTable.Name;
        assetBarCodeTmp.BarCode = this.barCode(assetTable.Barcode + assetTable.Name);

        netBitmap   = qrCode.Encode(assetTable.Barcode +' '+ assetTable.Name);
        filename    = qrCode.GetTempFile(assetTable.Barcode +' '+ assetTable.Name);
        perm        = new FileIOPermission(filename, 'RW');
        perm.assert();

        binData.loadFile(filename);
        assetBarCodeTmp.QRCode = binData.getData();

        assetBarCodeTmp.insert();
        
        CodeAccessPermission::revertAssert();
    }
}

Comments