Hello friends!
My customer wants me to change the auto numbered value for a Shipment to be the Shipment Number + the Customer ID (acctCD).
They promised that the acctCD for a customer is never going to be more than 5 characters. The shipment field is 15 characters so an example would be SHPXXXXXX-JOE1
I am trying to change the Shipment Nbr that is created when the Shipment is saved. I am using the RowPersisting event to do it.
However, even if I invoke the base handler at the start of the method, the ShipmentNbr field is still “<NEW>”.
I’m not sure where in the process I can get the Acumatica assigned ShipmentNbr and override it.
protected void SOShipment_RowPersisting(PXCache cache, PXRowPersistingEventArgs e, PXRowPersisting InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (SOShipment)e.Row;
//I THINK I should have the Shipment Nbr at this point but I don't
string custCD = string.Empty;
if (cache.GetStatus(row) == PXEntryStatus.Inserted)
{
BAccount2 customer = SelectFrom<BAccount2>.Where<BAccount2.bAccountID.IsEqual<@P.AsInt>>.View.Select(Base, row.CustomerID);
if (customer != null)
{
custCD = row.ShipmentNbr + "-" + customer.AcctCD.Substring(0, 5).Trim();
if (custCD.Trim().Length <= 15)
{
cache.SetValue(e.Row, "ShipmentNbr", custCD);
}
}
}
}
