Skip to main content
Solved

Device Hub Printing Errors

  • September 19, 2023
  • 7 replies
  • 217 views

Forum|alt.badge.img

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

Best answer by darylbowman

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?

View original
Did this topic help you find an answer to your question?

7 replies

darylbowman
Captain II
Forum|alt.badge.img+13

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


Forum|alt.badge.img
  • Author
  • Freshman I
  • 14 replies
  • September 20, 2023

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

 


darylbowman
Captain II
Forum|alt.badge.img+13

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.


Forum|alt.badge.img
  • Author
  • Freshman I
  • 14 replies
  • September 20, 2023

@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?


darylbowman
Captain II
Forum|alt.badge.img+13
  • 1698 replies
  • Answer
  • September 20, 2023

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?


Forum|alt.badge.img
  • Author
  • Freshman I
  • 14 replies
  • September 20, 2023

@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!


darylbowman
Captain II
Forum|alt.badge.img+13

Fantastic. You’re welcome!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings