Skip to main content
Solved

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


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

 

View original
Did this topic help you find an answer to your question?

6 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3409 replies
  • 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
  • 3409 replies
  • 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
  • 134 replies
  • 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
  • 3409 replies
  • 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
  • 134 replies
  • 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
  • 3409 replies
  • May 4, 2022

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings