I need to update some data on packages (the custom fields that print on label) automatically. I was able to PXOverride ConfrimShipment and update the fields but unfortunately, that happens too late as the label is already created at that point I assume. I tried all various/traditional ways of overriding the Action, many which complained were obsolete and would be deprecated in 2022 R2 (but they also just did not work or crashed the app). I tried doing a PXOverride on PrepareShipmentConfirmation since that appears to happen early in the process, however, for some reason the Carrier tracking number and url were not generated at all, but the status changed to Complete.
Ideally I just want my code to run right at the beginning where Save.Press() would typically get called:
This code runs (no errors) but it appears ShipPackages doesn’t work after doing this (no carrier tracking created), but shipment “completes” successfully.
[PXOverride]
public virtual void PrepareShipmentForConfirmation(SOShipment shiporder)
{
UpdatePackageDetails();
}
private void UpdatePackageDetails() {
ArrayList poValues = new ArrayList();
ArrayList soValues = new ArrayList();
string poNumbers = "PO# ";
string soNumbers = "TN# ";
// Build SO and PO number values
foreach (PXResult<SOOrderShipment, SOOrder> soItem in Base.OrderList.Select())
{
SOOrder so = (SOOrder)soItem;
poValues.Add(so.CustomerOrderNbr?.Trim());
soValues.Add(so.OrderNbr?.Trim());
}
poNumbers += String.Join(",", poValues.ToArray());
soNumbers += String.Join(",", soValues.ToArray());
poNumbers = poNumbers.Truncate(30);
soNumbers = soNumbers.Truncate(30);
foreach (SOPackageDetailEx pkg in Base.Packages.Select())
{
Base.Packages.Cache.SetValueExt<SOPackageDetailEx.customRefNbr1>(pkg, poNumbers);
Base.Packages.Cache.SetValueExt<SOPackageDetailEx.customRefNbr2>(pkg, soNumbers);
Base.Packages.Update(pkg);
}
Base.Packages.Cache.Persist(PXDBOperation.Update);
}
Any thoughts?
Best answer by Leonardo Justiniano
View original