Monday, April 19, 2010

Delete Actions

Sometimes its rare to have all the information about DELETE actions on the table and we read books and google it. This post will really helpful in describing how to create delete actions on tables and which Delete action should be used and when?
There are two purposes to define the delete actions on the table level;
§ Restrict the deletion of a record based on related records in another table
§ Cascade the deletion of a record to related tables to ensure data-consistency
How can I add delete actions in table?
Delete actions are added in the AOT, by right-clicking on the DeleteActions node of a Table AOT element. Select New DeleteAction and then select the table on which this delete action will be based.
There are three different types of delete actions
1. Cascade
2. Restricted
3. Cascade + Restricted
What are the basic 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
The delete action performs a restricted, if the record of the table will be deleted directly and performs a cascade, if the record of the table will be deleted through a cascade delete action of a other table.
For example:
When a record of SalesOrder table will be deleted, the restricted part of the deleteaction will be performed. The record of SalesOrder can only be deleted, if no record in SalesLine exist for the record in SalesOrder. (The SalesOrder can only be deleted, if no SalesLine exist for the SalesOrder).
A record in Customer will be deleted, so the cascade deleteaction to SalesOrder will be performed. In this case, the cascade part of the deleteaction to SalesLine will be performed. (When a Customer will be deleted, the SalesOrders and SalesLines will also be deleted)

How to enable new Microsoft teams - Public Preview!

New Microsoft Teams is just AWESOME, quick but useful post below shows how you have this preview feature to make your life EASY!  Open Micr...