Solved

How do I update the Cust Ref No 1 with Shipment Nbr on auto pack?


Userlevel 5
Badge +1

I am trying to get a newly added package to have the Shipment Number in the Customer Ref Nbr 1 field automatically.

 

To do this I added a fieldDefaulting event as follows:

 

    protected void SOPackageDetailEx_CustomRefNbr1_FieldDefaulting(PXCache cache,       PXFieldDefaultingEventArgs e)
{

var row = (SOPackageDetailEx)e.Row;

if (row == null) return;

e.NewValue = "SH#" + row.ShipmentNbr;

}

This works fine when I manually press to add a package but when I use auto pack it ends up with a field with: SH# <NEW> as I presume the row.ShipmentNbr is not populated at that point.  What should I use to get the shipment number before it is saved?

 

Thanks for any advice,

 

Phil

icon

Best answer by Naveen Boga 3 May 2022, 07:10

View original

6 replies

Userlevel 7
Badge +17

Most welcome, Phil and thanks a lot for sharing the update.

Userlevel 5
Badge +1

@Naveen Boga This seems to be working great!

Thanks so much,

Phil

Userlevel 7
Badge +17

Sorry, @ppowell  I have modified that code bit and please do verify with below and confirm.

 

I have verified from my end it is working as expected!!

 public class SOShipmentEntryExt : PXGraphExtension<SOShipmentEntry>
{
protected virtual void SOPackageDetailEx_RowPersisting(PXCache sender, PXRowPersistingEventArgs e, PXRowPersisting basecall)
{

SOPackageDetailEx row = (SOPackageDetailEx)e.Row;
if (row != null)
{
row.CustomRefNbr1 = "SH#" + row.ShipmentNbr;
Base.Packages.Cache.Update(row); // I just changed to Current record to ROW.
}
basecall?.Invoke(sender, e);
}
}

 

Userlevel 5
Badge +1

I tried it but I get the following when I try to save on the Shipment screen with either of the above:

An unhandled exception has occurred in the function 'MoveNext'. Please see the trace log for more details.

 

Phil

Userlevel 7
Badge +17

Hi @ppowell Above code might work but instead of using Current better use ROW like below.

 

protected virtual void SOPackageDetailEx_RowPersisting(PXCache sender, PXRowPersistingEventArgs e, PXRowPersisting basecall)
{
basecall(sender, e);
SOPackageDetailEx row = (SOPackageDetailEx)e.Row;
if (row != null)
{
row.CustomRefNbr1 = "SH#" + row.ShipmentNbr;
Base.Packages.Cache.Update(row); // I just changed to Current record to ROW.
}
}

 

Userlevel 7
Badge +17

Hi @ppowell Can you please try the below code and verify.

 

 protected virtual void SOPackageDetailEx_RowPersisting(PXCache sender, PXRowPersistingEventArgs e, PXRowPersisting basecall)
{
basecall(sender, e);
SOPackageDetailEx row = (SOPackageDetailEx)e.Row;
if (row != null)
{
row.CustomRefNbr1 = "SH#" + row.ShipmentNbr;
Base.Packages.Cache.Update(Base.Packages.Current);
}
}

 

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