Solved

Device Hub Printing Errors

  • 19 September 2023
  • 7 replies
  • 109 views

Userlevel 1
Badge

Hello,

I am trying to setup Device Hub to print a label for a file folder on an action. However I keep getting 2 errors which I cannot figure out what is causing them. Here are screenshots of the errors.

I am running DeviceHub as administrator on my device and I have given the user admin access rights. With the User, I am able to access the Printers page, Print Jobs page, and the report I am trying to print. Here is the code of the action:

protected void printFileLabel() {
PMProject project = (PMProject)Base.Project.Current;
Dictionary<string, string> printParams = new Dictionary<string, string>();
string projectID = project.ContractCD.ToString();
string projectIDDash = $"{projectID.Substring(0,2)}-{projectID.Substring(2,6)}-{projectID.Substring(8)}";
printParams["ARRetainageReportParameters.ProjectID"] = projectIDDash;

string actualReportID = "PM6210LB";

SMPrinter printer = PXSelect<
SMPrinter,
Where<SMPrinter.printerName, Equal<Required<SMPrinter.printerName>>>>
.Select(Base,"LABELDYMO");

PrintSettings printSettings = new PrintSettings()
{
PrinterID = printer.PrinterID,
NumberOfCopies = 1,
PrintWithDeviceHub = true,
DefinePrinterManually = false
};
PXGraph.CreateInstance<SMPrintJobMaint>().CreatePrintJob(printSettings, actualReportID, printParams, "Label Report for " + projectIDDash);
}

Please advise.

 

Thanks

icon

Best answer by darylbowman 20 September 2023, 16:01

View original

7 replies

Badge +11

I don't see anything wrong with your code. Have you set Access Rights AT ALL on that report for any role?

Userlevel 1
Badge

@darylbowman I granted access to the user that I am using to print. 

 

Badge +11

The user initiating the print action or the user logged into DeviceHub?

 

I asked specifically about ANY access because another acceptable solution would be to have all roles remain Not Set for that report, in which case everyone is granted access. Once you set access for one role, all others that are Not Set lose access.

I would personally recommend this option.

Userlevel 1
Badge

@darylbowman I have set the user logged into the DeviceHub to have access on the screen. Now I am getting the following error:

 

Any idea?

Badge +11

This StackOverflow answer suggests that there would be an error happening, resulting in an HTML error page instead of the XML report.

The ProjectID parameter you’re passing seems a little odd. Have you tried passing just the plain ContractCD instead of appending dashes?

Userlevel 1
Badge

@darylbowman I changed the field to the ProjectID and when I click the preview button, the report shows up correctly.

I also turned off the “Combine every ___ documents on printing” and now it is working.

Thanks for your help!

Badge +11

Fantastic. You’re welcome!

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