Skip to content

Latest commit

 

History

History
52 lines (40 loc) · 3.25 KB

PX1075.md

File metadata and controls

52 lines (40 loc) · 3.25 KB

PX1075

This document describes the PX1075 diagnostic.

Summary

Code Short Description Type Code Fix
PX1075 PXCache.RaiseExceptionHandling cannot be invoked from the FieldDefaulting, FieldSelecting, RowSelecting, and RowPersisted event handlers. Error Unavailable

Diagnostic Description

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 to PXCache 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 of PXCache.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 in PXCache yet. Invocation of PXCache.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 record
  • RowSelected 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.

Example of Incorrect Code

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;
    }
}

Related Articles