Skip to main content
Answer

Override Base Acumatica RowDeleting Event

  • August 6, 2024
  • 6 replies
  • 244 views

Forum|alt.badge.img

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.

 

 

Best answer by darylbowman

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;
}
}

 

6 replies

DipakNilkanth
Pro III
Forum|alt.badge.img+13

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!


darylbowman
Captain II
Forum|alt.badge.img+15

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
}

 


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • August 6, 2024

@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 


darylbowman
Captain II
Forum|alt.badge.img+15

Is the b.Invoke commented out? That's what would call the base handler.


darylbowman
Captain II
Forum|alt.badge.img+15
  • Answer
  • August 6, 2024

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;
}
}

 


darylbowman
Captain II
Forum|alt.badge.img+15

@nsmith51 Did you get this resolved?