Skip to main content
Solved

How to copy owner field from Sales Order to Shipment in 2025 R2

  • February 9, 2026
  • 1 reply
  • 13 views

lauraj46
Captain II
Forum|alt.badge.img+9

How can we copy the OwnerID field from rhw sales order when creating a shipment in 2025 R2? 

In prior versions we were overriding the method SetShipmentFieldsFromOrder in SOShipmentEntry.  In 2025 R2 there is a new CreateShipmentExtension and it looks like the override may need to be moved to the method SetShipmentFieldsFromOrigDocument(SOShipment shipment, CreateShipmentArgs args, bool newlyCreated)?

Below is our existing code.  It does not compile on 2025 R2 because the SetShipmentFieldsfromOrder method has been removed.  

  public class SOShipmentEntry2_Extension : PXGraphExtension<PX.Objects.SO.SOShipmentEntry>
{
[PXOverride]
public virtual bool SetShipmentFieldsFromOrder(
SOOrder order,
SOShipment shipment,
int? siteID,
DateTime? shipDate,
string operation,
SOOrderTypeOperation orderOperation,
bool newlyCreated,
Func<SOOrder, SOShipment, int?, DateTime?, string, SOOrderTypeOperation, bool, bool> baseMethod)
{
var contact = (Contact)SelectFrom<Contact>
.Where<Contact.contactID.IsEqual<@P.AsInt>>
.View.Select(Base, order.OwnerID);
shipment.OwnerID = contact?.ContactID;

return baseMethod(order, shipment, siteID, shipDate, operation, orderOperation, newlyCreated);
}
}
}

Thanks in advance for the help!

Laura

Best answer by lauraj46

Not sure if this is the recommend approach and I welcome feedback from the experts, but I was able to get this working using the RowInserted event on SOOrderShipment.

protected void _(Events.RowInserted<SOOrderShipment> e)
{
if (e.Row == null)
return;

// Get the shipment header
SOShipment shipment = PXSelect<SOShipment,
Where<SOShipment.shipmentNbr,
Equal<Required<SOShipment.shipmentNbr>>>>
.Select(Base, e.Row.ShipmentNbr);

if (shipment == null)
return;

// Do not overwrite if already set
if (shipment.OwnerID != null)
return;

// Get the originating SO
SOOrder order = PXSelectReadonly<SOOrder,
Where<SOOrder.orderType, Equal<Required<SOOrder.orderType>>,
And<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>>>>
.Select(Base, e.Row.OrderType, e.Row.OrderNbr);

if (order != null)
{
shipment.OwnerID = order.OwnerID;
Base.Document.Update(shipment);
}
}

 

1 reply

lauraj46
Captain II
Forum|alt.badge.img+9
  • Author
  • Captain II
  • Answer
  • February 10, 2026

Not sure if this is the recommend approach and I welcome feedback from the experts, but I was able to get this working using the RowInserted event on SOOrderShipment.

protected void _(Events.RowInserted<SOOrderShipment> e)
{
if (e.Row == null)
return;

// Get the shipment header
SOShipment shipment = PXSelect<SOShipment,
Where<SOShipment.shipmentNbr,
Equal<Required<SOShipment.shipmentNbr>>>>
.Select(Base, e.Row.ShipmentNbr);

if (shipment == null)
return;

// Do not overwrite if already set
if (shipment.OwnerID != null)
return;

// Get the originating SO
SOOrder order = PXSelectReadonly<SOOrder,
Where<SOOrder.orderType, Equal<Required<SOOrder.orderType>>,
And<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>>>>
.Select(Base, e.Row.OrderType, e.Row.OrderNbr);

if (order != null)
{
shipment.OwnerID = order.OwnerID;
Base.Document.Update(shipment);
}
}