Skip to main content
Answer

Update some data BEFORE ConfirmShipmentAction execution

  • May 19, 2022
  • 6 replies
  • 181 views

Forum|alt.badge.img+1

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

Have you tried updating the data while persisting  SOPackageDetailEx (Package)? Package is required to be able to confirm the shipment.

6 replies

jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • May 19, 2022

Hi @rjean09 

Can you please try like below,

 

 [PXOverride]
        public virtual IEnumerable Action(PXAdapter adapter, int? actionID, string actionName, Func<PXAdapter, int?, string, IEnumerable> baseAction)
        {
            if (actionID == SOShipmentEntryActionsAttribute.ConfirmShipment)
            {
               

               UpdatePackageDetails();  // Write the logic here
            }
            return baseAction(adapter, actionID, actionName);
        }


Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

Have you tried updating the data while persisting  SOPackageDetailEx (Package)? Package is required to be able to confirm the shipment.


Forum|alt.badge.img+1
  • Author
  • Semi-Pro III
  • May 19, 2022

Hi @rjean09 

Can you please try like below,

 

 [PXOverride]
        public virtual IEnumerable Action(PXAdapter adapter, int? actionID, string actionName, Func<PXAdapter, int?, string, IEnumerable> baseAction)
        {
            if (actionID == SOShipmentEntryActionsAttribute.ConfirmShipment)
            {
               

               UpdatePackageDetails();  // Write the logic here
            }
            return baseAction(adapter, actionID, actionName);
        }

Hi jinin,

I tried this but it never fires this code.  I attached my process and set a break to confirm and it never gets here:

 


Forum|alt.badge.img+1
  • Author
  • Semi-Pro III
  • May 19, 2022

Have you tried updating the data while persisting  SOPackageDetailEx (Package)? Package is required to be able to confirm the shipment.

Had not thought of trying this.  I’ll give it a shot.


Forum|alt.badge.img+1
  • Author
  • Semi-Pro III
  • May 19, 2022

Have you tried updating the data while persisting  SOPackageDetailEx (Package)? Package is required to be able to confirm the shipment.

That worked like a charm.  I wound up just hooking RowPersisting on the parent (SOShipment).

Apparently I marked my reply as the best answer and I don’t know how to undo that and change it :(


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • May 19, 2022

Hi @rjean09 - fixed the best answer 😀