Sequence of Events: Deletion of a Data Record

The figure below illustrates the sequence of events raised during the deletion of a data record.

Figure 1. Deletion of a data record


A data record is deleted when a user deletes the record on the user interface, the deletion request is sent through the Web Service API, or the Delete() method of a data view is invoked in code. As a result of the deletion, the data record gets the Deleted status if it already exists in the database, or the InsertedDeleted status if the record has just been inserted into the PXCache object and deletion from the database is not required. The data record is later available through the Deleted and Dirty collections of the PXCache object.

If the deletion has been initiated by a user on the UI or through the web services API, the following field events are raised for each key data field before any other events are raised:

  1. FieldUpdating
  2. FieldUpdated

Next, regardless of how the deletion was initiated, data record events are raised as follows:

  1. RowDeleting is raised. At this point, the developer can still stop the deletion by throwing a PXException instance. In the e variable representing event data, e.Row holds the data record being deleted.
  2. If e.Cancel does not equal true:
    1. RowDeleted is raised, and e.Row still holds the data record.
    2. RowSelected is raised, and e.Row equals NULL.
The data record will be reverted to the previous state and the RowDeleted event will not be raised if the delete operation is canceled.