This document describes the PX1075 diagnostic.
| Code | Short Description | Type | Code Fix |
|---|---|---|---|
| PX1075 | PXCache.RaiseExceptionHandling cannot be invoked from the FieldDefaulting, FieldSelecting, FieldUpdating, RowSelecting, and RowPersisted event handlers. |
Warning (Non-ISV) / Error (ISV) | Unavailable |
The PXCache.RaiseExceptionHandling method, 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 for some event handlers.
The PXCache.RaiseExceptionHandling method usually is invoked in the following event handlers:
RowPersistingto prevent saving of a record.RowSelectedto display an error or a warning on the form.
To prevent the diagnostic from showing an error, you should remove the code that invokes PXCache.RaiseExceptionHandling and rework the related business logic.
When Enable additional diagnostics for ISV Solution Certification Acuminator option (in Tools > Options > Acuminator > Code Analysis) is set to True,
the PX1073 diagnostic will be displayed as an error for the following event handlers:
FieldDefaulting: This event handler works with a record that has not yet been added toPXCacheor 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.RaiseExceptionHandlingin this event handler has no effect.FieldUpdating: This event handler is used to transform external value representation from the UI or Web API into the internal value representation stored in a DAC field. TheFieldUpdatingevent is not raised in some scenarios when Acumatica assumes that value is already in an internal state and does not require transformation. Therefore, the validation logic that callsPXCache.RaiseExceptionHandlingwon't be executed in all scenarios which can lead to an inconsistent state of the value in the DAC field. You should useFieldUpdatingor other event handlers for validation logic.RowSelecting: This event handler is called when the record is being read from the database. These records are not available inPXCacheyet. Invocation ofPXCache.RaiseExceptionHandlingin 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.
When Enable additional diagnostics for ISV Solution Certification Acuminator option (in Tools > Options > Acuminator > Code Analysis) is set to False,
the PX1073 diagnostic will be displayed as a Warning for the following event handlers:
FieldSelecting: This event handler is used to configure a UI control of a field. The invocation ofPXCache.RaiseExceptionHandlingin this event handler has no effect.FieldUpdating: This event handler is used to transform external value representation from the UI or Web API into the internal value representation stored in a DAC field. TheFieldUpdatingevent is not raised in some scenarios when Acumatica assumes that value is already in an internal state and does not require transformation. Therefore, the validation logic that callsPXCache.RaiseExceptionHandlingwon't be executed in all scenarios which can lead to an inconsistent state of the value in the DAC field. UseFieldUpdatingor other event handlers for validation logic.
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;
}
}