Instead of using RowPersisted, override the Persist event. Changes will be saved automatically:
protected override void Persist()
{
base.Persist();
// Your code
}
Hi @hotdok,
Please check This post as well.
If it’s in a graph extension, I believe it needs to look like this:
public delegate void PersistDelegate();
/PXOverride]
public void Persist(PersistDelegate baseMethod)
{
baseMethod();
}
Thanks. That both suggestions are workable solutions in general I have problem that ShipmentNbr is not set. Thus it doesn’t work for me.
Some additional information would be helpful.
ok I finally figured it out. We need to use RowPersisted event because only in this event all shipment values are already available. Then in order to save data in db we need to user PXDatabase object instead of Base.Save();
protected void SOShipment_RowPersisted(PXCache cache, PXRowPersistedEventArgs e)
{
// check if insert operation
if(e.Operation == PXDBOperation.Insert) {
// updating data in database
PXDatabase.Update<Obj>(
new PXDataFieldAssign<Obj.Val>(someval),
new PXDataFieldRestrict<Obj.Key>(PXDbType.Int, keyVal));
}
}
Thank you for sharing your solution with the community @hotdok!