• Zebra printer with Power Apps for D365FO


    MSDyn365FO: Print Product label to a ZPL printer from a PowerApp

    While ago I have posted a series of blogs that describe how to create a PowerApp that generates product labels. This app was embedded into Microsoft Dynamics 365 for Finance and Operations, it allowed to generate label with a barcode and open it as a pdf file in separate tab. In this solution I used ZPL language for label design and Microsoft Power Automate (MS Flow) to retrieve product specific data from MSDyn365FO. If you like to know more about this solution, then start reading from this post.

    Because PowerApps and Microsoft Power Automate do not support printing, we could print our label only via browser print option and could not redirect the label to a ZPL printer. There are some blogs on the web that show you how to solve this issue, for example, you could save a file to One drive folder and have PowerShell script or external app that monitors this folder and prints files from it. However, none of the options I saw was perfect.

    Therefore, I have got an idea to use Document routing agent for printing. We already know that it is capable to print ZPL labels, because we use it in Advanced warehouse management. The only gotcha here, is that there is no out of the box entity to add records into a printing queue. Kudos to a colleague of mine, Ievgen Miroshnikov, who helped me out to implement this solution. You can find it on a GitHub here, and in this post, I will create an example that shows you how to use it.

    To test my solution, I will setup a dummy printer. To do it, follow Step 2 from this blog.

    Then I have installed Document routing agent and enabled my printer in MSDyn365FO:

    PowerAppPrint_Network printers

    Considering that I created original app while ago, I no longer had that version, and I had to recreate it from the scratch. Therefore, I have used it as an opportunity to change and enhance it a bit. Below you can see what was modified:

    1. I have created parameters form that stores ZPL label design, this is to have one place to store the layout (ZPLLabelLayout field below that stores ZPL label text):PowerAppPrint_ParametersScreen
    2. I have added Layout button to the Main form (it opens Parameters screen where you can setup layout). Also, I have changed preview Image property to refer to ZPLLabelLayout field created above (previously I had here hardcoded ZPL label text):PowerAppPrint_MainScreen
    3. Finally, I have added print button that uses Microsoft Power Automate to trigger print action. On select I have specified my flow and passed ZPLLabelLayout field value to it:PowerAppPrint_PrintButton

     

     

    These are all the changes from PowerApp side. Let’s have a look at the created flow. We have two steps in the flow, one is a trigger another one is an action:

    PowerAppPrint_ExecuteActionFlow

    For the action step we need to specify following parameters:

    • Instance – link to MSDyn365FO instance
    • Action – data entity that was exposed to submit records to document routing agent queue
    • _printerName – Printer name from MSDyn365FO (note, I have hardcoded it, but you can retrieve all printers available from MSDyn365FO and add an option to select it in the PowerApp)
    • _label – label that we print, that is going to be a value we pass from PowerApp (ZPLLabelLayout.Text)

    All done and now it is time to test it. Open the App and click on the Print button:

    ProductLabelPrintingApp

     

    Check Document routing status form:

    PowerAppPrint_DocumentRoutingStatus

    Let’s check what was printed to the dummy printer:

    PowerAppPrint_Printer1PowerAppPrint_Printer2

    That is all, with minor changes to MSDyn365FO we have managed to create hassle-free and reliable printing solution. Not bad I would say!

  • 相关阅读:
    Nodejs读取文件时相对路径的正确写法(使用fs模块)
    node 读取多个文件、合并多个文件、读写多个文件
    js中typeof用法详细介绍
    express源码分析之Router
    14 Django的用户认证组件
    13-1 jquery操作cookie
    13 Django组件- cookie与session
    12 Django组件-form组件
    11 Django组件-分页器
    10 Django与Ajax
  • 原文地址:https://www.cnblogs.com/lingdanglfw/p/14141515.html
Copyright © 2020-2023  润新知