I have a processing screen that calls an action on the Sales Order screen (SO301000), which is intended to combine the custom Work Order report (PS652000) into a single PDF.
The action having the following code
public PXAction<SOOrder> printworkorder;
[PXUIField(DisplayName = "Print Job Order", MapEnableRights = PXCacheRights.Select)]
[PXButton(DisplayOnMainToolbar = false)]
protected virtual IEnumerable printWorkorder(PXAdapter adapter)
{
PSConfigReportMapping mapping = PXSelect<PSConfigReportMapping, Where<PSConfigReportMapping.jobType, Equal<Required<PSConfigReportMapping.jobType>>>>.Select(Base, "S");
PSConfig crow = PXSelect<PSConfig>.Select(Base);
string reportID = "PS652000";
List<SOOrder> list = adapter.Get<SOOrder>().ToList();
if (list.Count > 0)
{
Base.Save.Press();
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 (SOOrder order in list)
{
parameters = new Dictionary<string, string>();
parameters["OrderType"] = order.OrderType;
parameters["OrderNbr"] = order.OrderNbr;
parameters["JobCode"] = null;
parameters["PONumber"] = null;
object cstmr = PXSelectorAttribute.Select<SOOrder.customerID>(Base.Document.Cache, order);
actualReportID = new NotificationUtility(Base).SearchCustomerReport(reportID, order.CustomerID,
order.BranchID);
ex = PXReportRequiredException.CombineReport(ex, actualReportID, parameters, OrganizationLocalizationHelper.GetCurrentLocalization(Base));
ex.Mode = PXBaseRedirectException.WindowMode.New;
reportsToPrint = PX.SM.SMPrintJobMaint.AssignPrintJobToPrinter(reportsToPrint, parameters,
adapter, new NotificationUtility(Base).SearchPrinter, SONotificationSource.Customer,
reportID, actualReportID, order.BranchID, OrganizationLocalizationHelper.GetCurrentLocalization(Base));
actualReportID = null;
}
if (ex != null)
{
Base.LongOperationManager.StartAsyncOperation(async ct =>
{
await PX.SM.SMPrintJobMaint.CreatePrintJobGroups(reportsToPrint, ct);
throw ex;
});
}
}
return adapter.Get();
}
I
If I select more than one Sales Order to print the relevant Job Orders, it only prints one and does not combine the rest of the documents.
This works fine when called from the Sales Order action, but fails when executed from the Process screen.
While debugging the code, it goes through all the selected documents, but only the first one gets printed.
This was working fine earlier, but I’ve been facing this issue starting from version 24 R2.