Skip to content

Latest commit

 

History

History
48 lines (37 loc) · 2.13 KB

File metadata and controls

48 lines (37 loc) · 2.13 KB

PX1073

This document describes the PX1073 diagnostic.

Summary

Code Short Description Type Code Fix
PX1073 Exceptions cannot be thrown in the RowPersisted event handlers. Error Unavailable

Diagnostic Description

No exceptions of any type can be thrown in the RowPersisted event handlers.

The RowPersisted event handlers can be used for the following purposes:

  • Retrieval of the data from the database
  • Restoration of the values of the DAC fields if the status of the transaction scope is Aborted

An exception thrown in a RowPersisted event handler prevents the saving of the data to the database but does not roll back changes in PXCache instances, which leads to data inconsistency.

To prevent the error from occurring, you should remove the code that throws the exception and rework the related business logic. If you need to throw the exception to prevent saving of the record, you should use the RowPersisting event handler instead.

Example of Incorrect Code

protected virtual void SOOrderLine_RowPersisted(PXCache sender, PXRowPersistedEventArgs e)
{
    if (e.TranStatus == PXTranStatus.Completed)
    {
        if (e.Operation == PXDBOperation.Delete)
        {
            SOOrderLine row = (SOOrderLine)e.Row;
            SOOrderLine insertedLine = PXSelect<SOOrder,
                Where<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>>>
                .Select(this, row.orderNbr);
            if (insertedLine != null)
            {
                throw new PXException("Cannot delete"); //The PX1073 error is displayed for this line.
            }
        }
    }
}

Related Articles