4

I have the following code working which prints an address label from a Customer account:

public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint>
{
    #region PrintAddressLabelNH
    public PXAction<Customer> PrintAddressLabelNH;
    [PXUIField(DisplayName = "Print address label (NH)", Visible = false)]
    protected virtual void printAddressLabelNH()
    {
        var reportParams = new Dictionary<string, string>();
        string bAccountID = Base.CurrentCustomer.Current.BAccountID.ToString();
        reportParams.Add("BAccountID", bAccountID);
        var printSettings = new PrintSettings
        {
            PrintWithDeviceHub = true,
            DefinePrinterManually = true,
            PrinterID = new Guid("22BD7FCA-037C-4A8E-9145-2ADCFBF71BEE"),
            NumberOfCopies = 1
        };
        SMPrintJobMaint g = PXGraph.CreateInstance<SMPrintJobMaint>();
        g.AddPrintJob("Address label (NH)", printSettings, "GAARADCU", reportParams, null);
    }
    #endregion
}

I have this action configured on the 'Customers' Generic Inquiry as a mass action. The idea is that this is a way for someone to mass print address labels for Customers they filter to.

Selecting one Customer and using the mass action button to 'Print address labels' works great. But selecting multiple Customers in the same way throws up errors in the DeviceHub application (read bottom to top):

enter image description here

I am unable to determine what the cause could be. Does anyone have any helpful direction?

Deetz
  • 329
  • 1
  • 16
  • Malformed pdf? Errors look fine - no file, thus message. It does say BAccountID is not empty, and identifies user. Check that user data and where it is in batch (first, last, middle?). Accessing Base.CurrentCustomer.Current.BAccountID.ToString(); like this is error-prone (check real validation, such as null-checks, data integrity). Batch can be processed differently - async execution, forming batch etc. Especially list updates and reads. With async custom code can be error-prone. Would it print 2? Sample code is not concern. Pdf input is malformed, that is a problem. Mainly batch embed part. – d.stack Aug 03 '20 at 21:19
  • Thank you for you response. May I ask how you came to the conclusion that the PDF is malformed? It's just an Acumatica report with text fields. – Deetz Aug 03 '20 at 21:29
  • Warning section of the log. Before the error. It used all the attempts to poll for input. At least it expects a PDF, from what I can tell. If it is not and was not intended, then look at settings, mb PDF is expected default, whilst you sending another format. – d.stack Aug 04 '20 at 06:27

1 Answers1

1

Turns out both the code and report were fine. I had to uncheck 'Combine every [10] documents on printing' in DeviceHub.

Deetz
  • 329
  • 1
  • 16