We have a case where we want to conditionally auto number shipments based on if they were created via the API or via the UI. I've got that part figured out, but I can't figure out the best way to set the ShipmentNbr. I know that I can update the ShipmentNbr in the RowPersisting event before it is saved to the database (like below), but that doesn't update the ShipmentNbr in the other related tables (SOOrderShipment, SOShipLine, SOShipLineSplit, etc). I also tried looping through the related records and updating them individually, but that didn't work either. I could do it in the RowInserting event, but that causes issues when dealing with concurrency. Is there any way I can update the ShipmentNbr for the shipment and its related records?
public void SOShipment_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
SOShipment row = (SOShipment)e.Row;
if (row.ShipmentNbr.Trim() == "<NEW>")
{
row.ShipmentNbr = AutoNumberAttribute.GetNextNumber(sender, row, "SOSHIPMENT", DateTime.Now);
// this works, but doesn't update related records
}
}