Monday, April 22, 2013

Delete Actions in Dynamics AX

Introduction:-

The DeleteAction element helps maintain database consistency when a record is deleted. Define delete actions to specify what should occur when data being deleted in the current table is related to data in another table.


Adding a delete action:-

  • In the Application Object Tree (AOT), expand the Data Dictionary.
  • Expand Tables, and then locate the table that you want to add a delete action to.
  • Click the table, right-click DeleteActions, and then click New DeleteAction.
  • Right-click the new delete action, and then click Properties.
  • Select a related table from the Table property list.
  • Set the DeleteAction property. The following table describes the available values.


Types of Delete action:-


Cascade:

A cascading deletion action will delete all records in the related table, where the foreign key is equivalent to the primary key of the current table. That is, deleting the parent record will also delete the child record(s) in the related table.
This cascading will take place whether the deletion is performed in code or directly by a user through the user interface.


Restricted:

A restricting delete action will raise an error message if the user tries to delete a record, where records exist in the related table where the foreign key is equivalent to the primary key of the current table.
This error will only appear if the deletion is performed through the user interface. A deletion from X++ code will be allowed to proceed and will not be cascaded to the related table. In this case the programmer should call .validateDelete() themselves prior to the call to .delete()


Cascade+Restricted:

This delete action normally works as a Restricted delete action. However if the deletion is performed through X++ code, no error will be raised and the deletion will be cascaded to the related table.

No comments:

Post a Comment