How can I print Shipment Confirmation form SO642000 automatically upon status changing to Confirmed?
The user is confirming the shipments automatically upon the write-back after shipping in StarShip and they would like the Shipment Confirmation to print at that point.
I need to print the Shipment Confirmation form (via Device Hub if needed) when the Shipment status changes to Confirmed.
Thanks
Page 1 / 1
What version are you running? I believe this would be easy with the new workflow capabilities.
Good point.Using version 21.106
I would try flipping this Auto-Run Action to True and see what happens.
Brett
Thanks for the suggestion. I flipped the Print Shipment Confirmation to True. The report runs automatically and opens in a new tab with the right data. That would take us 50% of the way. The final step needs to be triggering the print job directly to DeviceHub. Any suggestions to achieve that?
I’d do this with a customization. You’d want to create a field updated event handler for the status field, check if the status switched to confirmed, and if it has, print the document. It should look something like this:
public class SOShipmentEntryExt : PXGraphExtension<SOShipmentEntry> {
protected void _(Events.FieldUpdated<SOShipment.status> e) { var row = (SOShipment)e.Row; if (row == null) return;
if ((string)e.OldValue != "F" && (string)e.NewValue == "F") { Dictionary<string, string> printParams = new Dictionary<string, string>(); printParamsa"Shipment Nbr"] = row.ShipmentNbr;
PXReportRequiredException ex = null; ex = PXReportRequiredException.CombineReport(ex, "Report ID", printParams);
Of course you’ll want to fill this out with your information, for example put your actual Report ID instead of literally “Report ID”. It still needs to be in quotes though. Also, make sure your parameters actually match for the report you’re trying to print. I just threw this together real quick as an example.
Also note, “F” is the value the database stores for confirmed shipments. That’s why that’s there.
The customization will be the way to go. Thank you all for your support.
@jknauf
Thanks for the insight on this one. I am to the same point that @gpineda64 was at that the PDF opening once confirmed. The script you wrote makes sense, but I want to be sure I am putting it in the correct place.
Under what portion of the customization would you place this script?