Solved

Update some data BEFORE ConfirmShipmentAction execution


Userlevel 3
Badge +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?

icon

Best answer by Leonardo Justiniano 19 May 2022, 19:13

View original

6 replies

Userlevel 7
Badge +11

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);
        }

Userlevel 6
Badge +4

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

Userlevel 3
Badge +1

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:

 

Userlevel 3
Badge +1

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.

Userlevel 3
Badge +1

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 :(

Userlevel 7
Badge

Hi @rjean09 - fixed the best answer 😀

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved