Hi @nsmith51,
Have you tried something like this?
protected void POLine_RowDeleting(PXCache cache, PXRowDeletingEventArgs e, PXRowDeleting InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (POLine)e.Row;
}
This is the Acumatica generated code for overriding base event from Customization editor.
Hope, it helps!
Except (I think) he doesn't want the base event to run, so it would look more like:
protected virtual void _(Events.RowDeleting<POLine> e, PXRowDeleting b)
{
POLine row = e.Row;
// b?.Invoke(e.Cache, e.Args);
if (row is null) return;
// Optional code
}
@darylbowman I tried this but it is still hitting the base code.
I my case, I do not want to hit base code and bypass a validation
Is the b.Invoke commented out? That's what would call the base handler.
Something like this may be even better, since you should probably allow the original functionality except whatever you’re trying to change:
protected virtual void _(Events.RowDeleting<POLine> e, PXRowDeleting b)
{
POLine row = e.Row;
try
{
b?.Invoke(e.Cache, e.Args);
}
catch (PXException ex)
{
// Check if ex.Message is the one you're trying to avoid and allow it through if NOT
if (ex.Message != PX.Objects.PO.Messages.POOrderLineHasReceiptsAndCannotBeDeleted)
{
throw ex;
}
else // If it is the one you're trying to avoid, allow the delete
e.Cancel = false;
}
}
@nsmith51 Did you get this resolved?