Printing label (zebra printer) with D365FO



D365FO & previous version (AX 2012) has in-built capability to print labels on zebra printer. But out-of-the-box, it only works for advanced warehouse module. This blogs discuss about use the same framework to print zebra printer labels from custom code.

Requirements

  1. Physical printer connected to local machine with internet
  2. Designer for the printer model to design ZPL or similar language text for the label design
  3. D365FO environment where printer setup needs to be done
  4. Access to azure environment (setup, subscriptions) to setup local printer on azure

The setup
First thing first, setup & connect the zebra printer & document routing between local environment and azure. https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/analytics/install-document-routing-agent

The design
Now based upon your printer model & label size, use zebra designer to design the required label & get the output zebra programing language (ZPL) text. It will looks something like this.

^XA

^FX Left section
^CFA,30
^FO50,50^FDSKU^FS
^CFA,40
^FO50,100^FD%ItemId%^FS
^BY3,2,100
^FO50,170^BC^FD%BarCode%^FS
^CFA,50
^FO50,350^FD%ItemName%^FS

^FX Right section
^CFA,40
^FO450,100^FD%Price%^FS
^CFA,20
^FO500,200^FD%PackQty%^FS
^FO500,250^FD%Location%^FS
^FO500,350^FD%Date%^FS

^XZ

The code will have placeholders like %ItemId%, which will fill on run-time with the data from AX for actual printing. You can use any format for placeholders but it should not conflict with any of the zebra tags.

The X++ code
Create a new Zebra printer layout table in AX for setup purpose. This should have at least two fields – Printer name & ZPL. Printer name will have the name of the printer installed in the system and ZPL (memo field) will have the output code from designer. You can add other fields if you have any more criteria to identify which layout should be used in your specific situation.
Create a simple form (& menu item, security artefacts etc.) to make this new table available in AX UI to enter data by user.

Create a new class which will act as a controller for printing. It can be called from the either a menu item or from other X++ code to give print. The class should have minimum two methods – getPrinterStr & sendToPrinter. First method will have the logic to get the correct layout record from the new layout table. Once layout is found, it will replace the placeholders in the string with actual from the source. This source can be a table, a view or some other business logic. For example

public str getPrinterStr(InventTable _inventTable)
{
                str retStr;
                if (_inventTable)
                                ZebraLayouts zl;
                                select firstOnly zl;
                                if (zl && zl.ZPL)
                                {
                                                retStr = zl.ZPL;
                                                retStr = strReplace(retStr, ‘%ItemId%’, _inventTable.itemId);
                                }
                }
                return retStr;
}

The second method ‘sendToPrinter’ will call the class ‘WHSDocumentRouting’ method ‘printLabelToPrinter’. This will require two arguments – actual printer name & the final printing string.

Other methods will be required to added to the class to make the flow work like main, if needs to be called from menu item.

Note: The same classes/tables are available in advanced warehouse code as well but currently it only work within the processes of the advance warehouse. You can choose to re-use those forms/tables. But it may conflict if you are using advance warehouse standard processes.

Comments

  1. I'm not sure why but this website is loading very slow for me. Is anyone else having this issue or is it a issue on my end? I'll check back later on and see if the problem still exists.
    best supplements on the market

    ReplyDelete
  2. Howdy would you mind stating which blog platform you're using? I'm looking to start my own blog in the near future but I'm having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most blogs and I'm looking for something unique. P.S Apologies for getting off-topic but I had to ask!
    supplement manufacturers

    ReplyDelete
  3. I'm not sure why but this site is loading very slow for me. Is anyone else having this issue or is it a problem on my end? I'll check back later on and see if the problem still exists.
    custom supplement formulation

    ReplyDelete
  4. Hello are using Wordpress for your site platform? I'm new to the blog world but I'm trying to get started and create my own. Do you need any html coding knowledge to make your own blog? Any help would be really appreciated!
    best supplements on the market

    ReplyDelete
  5. I appreciate the way you have formatted the article. It looks like a proper guide to label printing. Keep it up!

    ReplyDelete
  6. Sweet blog! I found it while searching on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I've been trying for a while but I never seem to get there! Thanks
    private label sports nutrition

    ReplyDelete
  7. When the stickers are firmly in place, whether

    it is by gluing them or starting with stickers that stick to plastic, youneed to seal them with two or

    three coats of decoupage glue.
    This step permanently adheres the stickers to the plastic surface,

    and it also protects the stickers from wear and tear.

    ReplyDelete
  8. When I originally commented I clicked the "Notify me when new comments are added" checkbox and now each time a comment is added I get three e-mails with the same comment. Is there any way you can remove me from that service? Cheers!
    sports nutrition manufacturers

    ReplyDelete
  9. Thanks for your entire hard work on this website. Debby takes pleasure in conducting investigation and it is obvious why. My spouse and i hear all of the lively way you render precious tips by means of this website and therefore recommend participation from the others on that point while my child is actually learning so much. Take advantage of the remaining portion of the new year. Your doing a splendid job.
    best supplements on the market

    ReplyDelete
  10. Hello! Would you mind if I share your blog with my facebook group? There's a lot of people that I think would really enjoy your content. Please let me know. Thanks
    private label supplements

    ReplyDelete
  11. My grandma can’t sew my jerseys anymore. I ordered Cut and Sew Apparel Contractors. The H&A Global Enterprises have so many amazing jerseys I have no idea.

    ReplyDelete
  12. I appreciate the way you have formatted the article.
    A barcode scanner can read the specific sequence of bars and spaces, which indicate numbers and other things. Similarly, a Zebra barcode printer is available to print the barcode labels.

    ReplyDelete
  13. I just want to say you have a great idea about this but this will add more in your experiencewhere to buy zebra printersit will be very helpful for you

    ReplyDelete
  14. Thanks for sharing the blog.
    Get a professional, low-cost alternative to expensive pre-made barcode labels. Whether you're in the manufacturing or shipping/receiving business, our large 4" x 6" labels are compatible with Zebra and other leading barcode label printers.

    ReplyDelete

Post a Comment

Popular Posts