This document describes the PX1073 diagnostic.
Code | Short Description | Type | Code Fix |
---|---|---|---|
PX1073 | Exceptions cannot be thrown in the RowPersisted event handlers. |
Error | Unavailable |
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.
This diagnostic is displayed as a warning if the Enable additional diagnostics for ISV Solution Certification option (in Tools > Options > Acuminator > Code Analysis) is set to False
.
The diagnostic does not show an error for the exception thrown in the RowPersisted
event handler of a graph if at least one of the following conditions is met:
- The graph declaring the
RowPersisted
event handler is a processing graph. For processing graphs all exception types are allowed. - The graph declaring the
RowPersisted
event handler is a non-processing graph and the type of the exception is among one of the following exception types or is derived from them:PX.Data.PXRowPersistedException
PX.Data.PXLockViolationException
- .NET exceptions from the System namespace:
NotImplementedException
,NotSupportedException
,ArgumentException
(including its descendantsArgumentNullException
andArgumentOutOfRangeException
)
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.
}
}
}
}