I'm trying to create a button that will run both the Print Labels and Print Shipment Confirmation actions for a shipment. I found some examples in the Acumatica base code that look to run one action, then wait, then run another, but it's not working for me. Below is one of the code examples I'm trying. The order which they run doesn’t matter. Everything I’ve tried either doesn't run the second action, or doesn’t run either action. I think I'm having trouble because one returns files and the other runs a report. Any ideas on what to do?
public PXAction<SOShipment> printCombinedLabelShipmentConfirmation;
[PXButton(CommitChanges = true), PXUIField(DisplayName = "Print Labels/Packing Slip", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
public virtual IEnumerable PrintCombinedLabelShipmentConfirmation(PXAdapter adapter)
{
var list = adapter.Get<SOShipment>().ToList();
var key = Guid.NewGuid();
var printArgs = new PrintPackageFilesArgs
{
Shipments = list,
Adapter = adapter,
Category = PackageFileCategory.CarrierLabel
};
Base.LongOperationManager.StartAsyncOperation(key, ct => Base.PrintPackageFiles(printArgs, ct));
Base.LongOperationManager.WaitCompletion(key);
Base.printShipmentConfirmation.Press();
return list;
}