How to allow Deleting of row in RowPersisting method of Acumatica

Hello everybody,

today I want to tell interesting behavior of method RowPeristing in Acumatica graphs. Try to guess, after which actions of user that event is getting called? Save ? Yes. Delete? Also yes! Insert? Also yes. 

If you ask me why? I'll not provide you an anser. But I want to leave a piece of code which describes how to understand which action was called. I'll demonstrate it on sample of SOShipLine, and you'll be able to use it for other DAC classes, with slight modificaitons.

Here you can see two cases:

protected void SOShipLine_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
    var soShipLine = e.Row as SOShipLine;
    if (sender.GetStatus(soShipLine) == PXEntryStatus.Deleted) // Delete was pressed
        return;
    if (sender.GetStatus(soShipLine) == PXEntryStatus.Inserted) // Delete was pressed
        return;

Why such staff is important? In my case I throwed some exceptions which ought to happen before Shipline can be persisted to database. And not affect other actions. For that purpose I've used method GetStatus

No Comments

Add a Comment