Skip to main content
Answer

Sales Order - shipping address override

  • June 21, 2023
  • 4 replies
  • 318 views

Forum|alt.badge.img

Hi,

Customer would like to have the Override Address checkbox set to true as the default on the Sale Order.I have not been able to get a customization to work.  Any help would be appreciated.

 

Thanks,

Coleen

Best answer by jinin

Hi @coleenmcnally22 

If we assign the PXDefault or PXDefaulting event for the override address field, it doesn't work. However, we can write the code in the Customer Field Updated event, and it works.

Please refer to the code snippet below:

  protected void SOOrder_CustomerID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
        {
            if (InvokeBaseHandler != null)
                InvokeBaseHandler(cache, e);
            var row = (SOOrder)e.Row;

            if (Base.Shipping_Address.Select().FirstOrDefault() != null)
            {
                Base.Shipping_Address.Current = Base.Shipping_Address.Select().FirstOrDefault();
                Base.Shipping_Address.Current.OverrideAddress = true;
                Base.Shipping_Address.Update(Base.Shipping_Address.Current);              
            }

        }
 

4 replies

jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • Answer
  • June 21, 2023

Hi @coleenmcnally22 

If we assign the PXDefault or PXDefaulting event for the override address field, it doesn't work. However, we can write the code in the Customer Field Updated event, and it works.

Please refer to the code snippet below:

  protected void SOOrder_CustomerID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
        {
            if (InvokeBaseHandler != null)
                InvokeBaseHandler(cache, e);
            var row = (SOOrder)e.Row;

            if (Base.Shipping_Address.Select().FirstOrDefault() != null)
            {
                Base.Shipping_Address.Current = Base.Shipping_Address.Select().FirstOrDefault();
                Base.Shipping_Address.Current.OverrideAddress = true;
                Base.Shipping_Address.Update(Base.Shipping_Address.Current);              
            }

        }
 


Forum|alt.badge.img

So the code above will the override default as always true on the address tab on the SO?

 


jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • June 26, 2023

Yes @coleenmcnally22 , Once you select the customer, always the checkbox should be true.


Forum|alt.badge.img

Thanks...it worked!