ax / d365fo – Adding Barcode to a Report

First, create a method like the following either on your Report element or in the relevant Section.

display str 30 barcodeRefNum()
{
    Barcode     barcode;
    ;

    barcode = Barcode::construct(BarcodeType::Code128);
    barcode.string(true, custPackingSlipJour.packingSlipId);

    return barcode.barcodeStr();
}

Note the BarcodeType enumeration that provide you with options other than 128.

Then, add a String control to your report and use your new method as the data method.  You could also have attached the display method directly to the underlying table if that’s better for you.  Finally, set the width, height, and alignment, and finally the font to your required symbology, i.e. “BC C128 Wide”.  Code 39, 128, UPC, and several others come with the Dynamics AX client.

4 responses to “ax / d365fo – Adding Barcode to a Report”

  1. Hugo Alves Avatar
    Hugo Alves

    This is working perfectly. Thanks for sharing.
    We have a problem when printing directly to a network Printer… the barcode shows properly if i print to File:PDF or to Screen instead.
    I have no clue on how to manage installed fonts for D365FO hosted environment.

    Like

    1. Marco Saad Avatar
      Marco Saad

      Environment is onpremise?

      Like

      1. Hugo Alves Avatar
        Hugo Alves

        It is Cloud Hosted,
        I am a developer, i don’t know much on infra, but even the infra guy that manages customer’s environment says he has no access to install fonts.

        Like

  2. Marco Saad Avatar
    Marco Saad

    I know how to install fonts only on on-premise environments. For cloud envs ì dont think it’s possibile. Try to https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/analytics/supported-fonts

    Like

Leave a comment