Solved

Does anyone have experience with printing custom labels (Acumatica reports) to device hub? 

  • 13 August 2021
  • 1 reply
  • 712 views

Userlevel 1

Label Customization to Send Custom Report to Device Hub Returning "0 Documents added to Buffer"
 
We are developing a label printing customization and are integrating with Acumatica device hub.  The customization is successfully creating jobs in device hub but is not adding any documents to the buffer.  I have attached our current customization project which issues print commands from the ‘print label’ button added to the Purchase Receipts screen.  It will print to a device hub printer hardcoded during testing to with Printer ID = ‘LABEL-01’.  Please see the screenshot below for more information about the error. 

icon

Best answer by Gabriel Michaud 13 August 2021, 20:35

View original

1 reply

Userlevel 7
Badge +10

Hi Robert,

What version of Acumatica are you building this on? I looked at current print job code in 2021 R1 and it calls a slightly different combination of functions, AssignPrintJobToPrinter and CreatePrintJobGroups. I haven’t seen a single place where CreatePrintJob is currently used in PX.Objects.

                Dictionary<string, string> parameters = new Dictionary<string, string>();
string actualReportID = null;

PXReportRequiredException ex = null;
Dictionary<PX.SM.PrintSettings, PXReportRequiredException> reportsToPrint = new Dictionary<PX.SM.PrintSettings, PXReportRequiredException>();

foreach (FSContractSchedule schedule in list)
{
parameters = new Dictionary<string, string>();
parameters["FSServiceContract.RefNbr"] = CurrentServiceContract.Current?.RefNbr;
parameters["FSSchedule.RefNbr"] = schedule.RefNbr;

object customer = PXSelectorAttribute.Select<FSContractSchedule.customerID>(ContractScheduleSelected.Cache, schedule);
actualReportID = new NotificationUtility(this).SearchReport(SO.SONotificationSource.Customer, customer, reportID, schedule.BranchID);
ex = PXReportRequiredException.CombineReport(ex, actualReportID, parameters);

reportsToPrint = PX.SM.SMPrintJobMaint.AssignPrintJobToPrinter(reportsToPrint, parameters, adapter, new NotificationUtility(this).SearchPrinter, SO.SONotificationSource.Customer, reportID, actualReportID, schedule.BranchID);
}

if (ex != null)
{
PX.SM.SMPrintJobMaint.CreatePrintJobGroups(reportsToPrint);

throw ex;
}

I would try to do it this way (you can ignore the CombineReport portion since you’re only printing one document).

Something else that you should check is the type of printer that you are sending this to - DeviceHub supports raw mode (used to send ZPL code directly to a label printer), and traditional GDI printing (to send a PDF or image to the printer). I noticed that you are hardcoding this job to a label printer that’s set for raw mode in DeviceHub, it will certainly not be able to handle a standard Acumatica report. Note that it is possible to generate ZPL code on the fly, it is definitely the fastest way to print labels to a label printer.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved