Hi All,
There is an nice function in Acumatica 2018R1 – Device Hub. This service can be installed on any machine where printer is configured/available and automatically pull Acumatica for documents need to be printed.
There are a lot of screens who uses this function in the standard Acumatica already, but today I want to give you a quick look on how you can write your custom code and send request to printers.
Device Hub
First of All device hub should be installed on your computer, connected to Acumatica and configured with Available printers.
Printers also should be Configured in Acumatica.
Customization
Now we can write a bit of code. I’ll create a button on Invoice and Memos screen where I can print 2 documents in unattended more using 2 printers I have created.
Actually all work for printing documents is done thought PX.SM.SMPrintJobMaint and you can pass there name of the report and parameters the same way how you throw PXReportRequiredException. Just call CreatePrintJob method and pass there required data.
namespace PX.Objects.AR { public class ARInvoiceEntry_Extension : PXGraphExtension<ARInvoiceEntry> { #region Event Handlers public PXAction<PX.Objects.AR.ARInvoice> Printer; [PXButton(CommitChanges = true)] [PXUIField(DisplayName = "Printer")] protected void printer() { ARInvoice invoice = Base.Document.Current; Dictionary<string, string> printParams = new Dictionary<string, string>(); printParams["ARInvoice.DocType"] = invoice.DocType; printParams["ARInvoice.RefNbr"] = invoice.RefNbr; PXReportRequiredException ex = null; ex = PXReportRequiredException.CombineReport(ex, "AR641000", printParams); PX.SM.SMPrintJobMaint.CreatePrintJobGroup("PRINTER1", ex, "Report 1"); //Job1 PX.SM.SMPrintJobMaint.CreatePrintJobGroup("PRINTER2", ex, "Report 2"); //Job2 } #endregion } }
Now if you click the button on the screen, you can see how job is send to the printers:
Hope it helps and have a nice day!
Hi Sergey
Thanks for this code, its great. Quick question about documentation, where can i find any documentation about the SMPrintJobMaintenance ?
I’m really sorry Dean, but i’m not aware of any documentation on this code.
Is there a way to run that code to the default printer on the users profile, instead of present in the code? Thanks
Hi Steve, you can modify the code to read the printer name from the user profile.
Unfortunately I have no example of this here.
Hi Sergey,
It seems that in the recent build of Acumatica, they’ve changed the parameters for the CreatePrintJobGroup function. Any update on how to use the new function to achieve the same outcome?
Thanks!
Hi Sergey
Do you maybe have a new way to print with the CreatePrintJobGroup function. The paramater doesn’t take the printer name. – Only the PX Adapter or printer settings
I will take a look at the code and will try to update it but it will take a while.
HI
Any Idea how to make an Invoice print via device hub once status changes to open?
I tried using automation steps but could not find a way to actually trigger the print ( only figured out how to show the print invoice option in the menu)
Hi Sergey,
I setup Device Hub and got error “An error occured while polling the print queue:”
Please note that the following steps have been done
1.In DeviceHub, I’m able to logging to the site and configured printer
2.In ERP site, I have setup print queue with the name (via SM206510) as same as print queue name configured in Device Hub.
Please advise any configuration missing.
I found that the root cause is Device Hub try to send HttpGet with https:///PushNotifications/PX.SM.PrintQueueNotificationsDefinition and it is fail (StatusCode: 404).
Do you have any idea about PX.SM.PrintQueueNotificationDefinition? Why is it appended to Uri?
Hi Vo, looks like a configuration problem, that needs to be reviewed.
Please create a case on support portal. Our support team will help you to check the problem.
Hi Sergey,
Thanks so much for helping me resolve this. If it was not for this post and your fast and accurate assistance we would have had a serious problem with the current implementation i am busy with. This is an awesome solution and it runs like clockwork. You saved the client from spending a fortune on 3rd party solutions.