This document describes the PX1075 diagnostic.
Code | Short Description | Type | Code Fix |
---|---|---|---|
PX1075 | PXCache.RaiseExceptionHandling cannot be invoked from the FieldDefaulting , FieldSelecting , RowSelecting , and RowPersisted event handlers. |
Error | Unavailable |
RaiseExceptionHandling
, which is used to prevent the saving of a record or to display an error or warning on the form, cannot be invoked on a PXCache
instance in the following event handlers:
FieldDefaulting
: This event handler works with a record that has not yet been added toPXCache
or a record whose field is changed in the code. Neither situation involves the display of errors or warning for a record.FieldSelecting
: This event handler is used to configure a UI control of a field. The invocation ofPXCache.RaiseExceptionHandling
in this event handler has no effect.RowSelecting
: This event handler is called when the record is being read from the database. These records are not available inPXCache
yet. Invocation ofPXCache.RaiseExceptionHandling
in this event handler has no effect.RowPersisted
: This event handler is called when the record has already been saved to the database. Therefore, it would not make sense to display any warnings for this record.
RaiseExceptionHandling
usually is invoked in the following event handlers:
RowPersisting
to prevent saving of a recordRowSelected
to display an error or warning on the form
To prevent the error from occurring, you should remove the code that invokes PXCache.RaiseExceptionHandling
and rework the related business logic.
This diagnostic is displayed as a warning for the FieldSelecting
event handler if the Enable additional diagnostics for ISV Solution Certification option (in Tools > Options > Acuminator > Code Analysis) is set to False
.
protected virtual void SOOrder_Status_FieldSelecting(PXCache sender,
PXRowSelectingEventArgs e)
{
SOOrder row = (SOOrder)e.Row;
if (row.Status != "New" )
{
sender.RaiseExceptionHandling<SOOrder.status>( //The PX1075 error is displayed for this line.
row, null,
new PXSetPropertyException(
Messages.SpecialText,
typeof(SOOrder.status).Name));
e.Cancel = true;
}
}