Skip to main content

Hi Everyone,

In the Purchase Order, I would like to override the Base Acumatica (POLine_RowDeleting) event to bypass a validation. I tried with the RemoveHandler but still it is hitting the Base event.

Can you please provide sample example to override the Base Acumatica event.

 

 

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?


Reply