Skip to main content
Answer

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

  • May 2, 2022
  • 6 replies
  • 220 views

Forum|alt.badge.img+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

Best answer by Naveen Boga

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

 

6 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • May 2, 2022

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

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • May 2, 2022

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.
}
}

 


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

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


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • May 3, 2022

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

 


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

@Naveen Boga This seems to be working great!

Thanks so much,

Phil


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • May 4, 2022

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