{"id":108,"date":"2021-07-15T07:47:14","date_gmt":"2021-07-15T07:47:14","guid":{"rendered":"https:\/\/iani.co\/blog\/?p=108"},"modified":"2021-10-25T11:36:12","modified_gmt":"2021-10-25T11:36:12","slug":"badge-printing-with-power-apps-2-finding-the-way-to-send-the-print-job-to-the-printer","status":"publish","type":"post","link":"https:\/\/iani.co\/blog\/badge-printing-with-power-apps-2-finding-the-way-to-send-the-print-job-to-the-printer\/","title":{"rendered":"Badge printing with Power Apps \u2013 2. Sending the print job to the printer"},"content":{"rendered":"\n<p><em>This is part of the series <strong><a href=\"https:\/\/iani.co\/blog\/badge-printing-and-more-with-power-apps\/\">Badge printing and more with Power Apps<\/a><\/strong><\/em><\/p>\n\n\n\n<p>After <a href=\"https:\/\/iani.co\/blog\/badge-printing-with-power-apps-checking-the-printing-requirements-of-the-chosen-printer\/\" title=\"Badge printing with Power Apps \u2013 Checking the printing requirements of the chosen printer\">choosing the printer<\/a> the challenge was to send the print job to it. As explained in the previous post, the printer would be available only on local network, so there is no direct access from Internet to it. That&#8217;s why we had to establish a link between Power Apps (Microsoft 365) and the local IP address of our printer (on-premises network) and send the print job.<\/p>\n\n\n\n<h2>But how? <\/h2>\n\n\n\n<p>Let&#8217;s describe the process from the end to start:<\/p>\n\n\n\n<ul><li>The badge would be printed by the <strong>printer<\/strong><ul><li>the Brother printer understands <strong>ESC\/P commands<\/strong><ul><li>containing the ESC\/P commands, a file should be generated including the <strong>visitor information<\/strong><ul><li>the visitor information should be transferred to a local server by a <strong>Flow (Power Automate)<\/strong><ul><li>the Flow collects the visitor information from <strong>Power Apps App<\/strong><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><\/ul>\n\n\n\n<p>Ok, now let&#8217;s start from the beginning like normal people \ud83d\ude42<\/p>\n\n\n\n<h2>The Flow collects the visitor information from Power Apps App<\/h2>\n\n\n\n<p>This step is straightforward, one needs to create a Flow which will be called by the Power Apps app using parameters.<br>There is a template for that called &#8220;Power Apps button&#8221;. I recommend you <a href=\"https:\/\/www.youtube.com\/watch?v=emAhLzVG9bM\" target=\"_blank\" rel=\"noreferrer noopener nofollow\" title=\"https:\/\/www.youtube.com\/watch?v=emAhLzVG9bM\">this video<\/a> about how to handle the parameters generated by &#8220;Ask in PowerApps&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"280\" height=\"205\" src=\"https:\/\/iani.co\/blog\/wp-content\/uploads\/2021\/07\/grafik.png\" alt=\"\" class=\"wp-image-124\"\/><\/figure>\n\n\n\n<p>We are passing the following information from Power Apps: first name, last name and company name.<\/p>\n\n\n\n<h2>The visitor information should be transferred to a local server by a Flow (Power Automate)<\/h2>\n\n\n\n<p>In the Flow created in the previous step we need to add a new action and generate a .txt file and save it on a local server. Here comes the on-premises data gateway in action:<br><\/p>\n\n\n\n<h3>On-premises data gateway<\/h3>\n\n\n\n<p>Microsoft has that figured out and provides local access through the <a href=\"https:\/\/docs.microsoft.com\/en-us\/power-bi\/connect-data\/service-gateway-onprem\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"https:\/\/docs.microsoft.com\/en-us\/power-bi\/connect-data\/service-gateway-onprem\">On-premises data gateway<\/a>. The service was originally built for PowerBI (hence the service name PBIEgwService) but it can be used by the Power Platform products: Power Automate, Power Apps. <\/p>\n\n\n\n<p><em>Be aware that the on-premises gateway is a premium feature and requires a premium license!<\/em><\/p>\n\n\n\n<h4>Installation and configuration<\/h4>\n\n\n\n<ul><li>Installing the gateway<\/li><li>Signing in and configuring proxy (if needed) and service user<\/li><li>Test connectivity<\/li><li>Test if service is running<\/li><\/ul>\n\n\n\n<p>After that this new gateway should appear in the list in Power Automate Portal -&gt; Data  -&gt; Gateways<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"199\" height=\"210\" src=\"https:\/\/iani.co\/blog\/wp-content\/uploads\/2021\/07\/grafik-1.png\" alt=\"\" class=\"wp-image-127\"\/><\/figure>\n\n\n\n<h4>Adding a new connection in Power Automate using the newly created Gateway<\/h4>\n\n\n\n<p>In order to generate and save a file on a local server we must create a new connection using the gateway.<br>This is done in Power Automate Portal -&gt; Data -&gt; Connections -&gt; New Connection -&gt; File System<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"571\" src=\"https:\/\/iani.co\/blog\/wp-content\/uploads\/2021\/07\/grafik-2-1024x571.png\" alt=\"\" class=\"wp-image-128\" srcset=\"https:\/\/iani.co\/blog\/wp-content\/uploads\/2021\/07\/grafik-2-1024x571.png 1024w, https:\/\/iani.co\/blog\/wp-content\/uploads\/2021\/07\/grafik-2-300x167.png 300w, https:\/\/iani.co\/blog\/wp-content\/uploads\/2021\/07\/grafik-2-768x428.png 768w, https:\/\/iani.co\/blog\/wp-content\/uploads\/2021\/07\/grafik-2.png 1288w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>Root folder<\/strong> is required and must a folder path (e.g. \\MACHINE\\myShare or C:\\FolderName)<br><strong>Authentication Type<\/strong> is &#8220;Windows&#8221;<br><strong>Username <\/strong>is required and is the local username credential (e.g. DOMAIN\\Username)<br><strong>Password <\/strong>is required and is the local password credential<br><strong>Gateway <\/strong>is required and is a selection of created gateways<br><br>Here is the official Microsoft documention about the <a href=\"https:\/\/docs.microsoft.com\/en-us\/connectors\/filesystem\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\" title=\"https:\/\/docs.microsoft.com\/en-us\/connectors\/filesystem\/\">File System Connector<\/a><\/p>\n\n\n\n<p>Now we are able to add &#8220;<a href=\"https:\/\/docs.microsoft.com\/en-us\/connectors\/filesystem\/#create-file\" title=\"https:\/\/docs.microsoft.com\/en-us\/connectors\/filesystem\/#create-file\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Create File<\/a>&#8221; operation using the <strong>Connection <\/strong>created above and specifying then path and the file contents.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"616\" height=\"60\" src=\"https:\/\/iani.co\/blog\/wp-content\/uploads\/2021\/07\/grafik-3.png\" alt=\"\" class=\"wp-image-131\" srcset=\"https:\/\/iani.co\/blog\/wp-content\/uploads\/2021\/07\/grafik-3.png 616w, https:\/\/iani.co\/blog\/wp-content\/uploads\/2021\/07\/grafik-3-300x29.png 300w\" sizes=\"(max-width: 616px) 100vw, 616px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>In the next blog post from this series we will handle the ESC\/P commands and converting the collected visitor information to a format that can be understood by the printer.<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is part of the series Badge printing and more with Power Apps After choosing the printer the challenge was to send the print job to it. As explained in the previous post, the printer would be available only on local network, so there is no direct access from Internet to it. That&#8217;s why we [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[19,16,18],"tags":[],"_links":{"self":[{"href":"https:\/\/iani.co\/blog\/wp-json\/wp\/v2\/posts\/108"}],"collection":[{"href":"https:\/\/iani.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iani.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iani.co\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iani.co\/blog\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":24,"href":"https:\/\/iani.co\/blog\/wp-json\/wp\/v2\/posts\/108\/revisions"}],"predecessor-version":[{"id":146,"href":"https:\/\/iani.co\/blog\/wp-json\/wp\/v2\/posts\/108\/revisions\/146"}],"wp:attachment":[{"href":"https:\/\/iani.co\/blog\/wp-json\/wp\/v2\/media?parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iani.co\/blog\/wp-json\/wp\/v2\/categories?post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iani.co\/blog\/wp-json\/wp\/v2\/tags?post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}