Showing posts with label AOT. Show all posts
Showing posts with label AOT. Show all posts

Monday, 4 February 2013

Delete Actions in AX


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.

For example, use a cascading delete action to specify that the system is to delete a customer's address when that customer is deleted from the CustTable table. Another example is to use a restricted delete action to prevent a customer from being deleted from the CustTable if one or more transactions exist for the customer in the CustTrans table.

Use the following best practices.

  • Have a delete action on every relation between two tables.
  • Use table delete actions instead of writing code to specify whether deletes are restricted or cascaded

Delete Action
Description
Comments
None
Delete action disabled
Cascade
Deletes related records
Setting the DeleteAction property to Cascade extends the functionality of the table's delete method. As a result,super(), in delete, initiates a cascaded deletion, propagating the delete from table to table.
A cascaded delete is implicitly protected by tts. Database changes aren't committed until the entire transaction is complete.
Example
On the CustTable table, a cascading delete action has been defined for the CustBankAccount table. When a customer is deleted from the CustTable table, the delete method also ensures that the corresponding bank account information is automatically deleted.
Restricted
Restricts deletion in the current table if data is present in related tables.
Setting the DeleteAction property to Restricted extends the functionality of the table's validateDelete method.
As a result, super(), in validateDelete, checks whether records exist on related tables. If records do exist,validateDelete returns false. The forms system ensures that the deletion is not performed. In your own X++ code, check the return value of validateDelete. Don't delete the primary or related records if the method returns false.
Example
On the CustTable table, a restricted delete action has been defined for the CustTrans table. When a customer is deleted in the CustTable table, the validateDelete method ascertains whether transactions exist for the customer in the CustTrans table. If so, validateDelete returns false.
Cascade+Restricted
Cascade the delete, even though records exist on related tables.
Setting the DeleteAction property to Cascade+Restricted extends the functionality of the table's validateDeleteand delete methods.
As a result, super(), in validateDelete, ascertains whether records exist on related tables. Whether deleting records from forms or X++, if validateDelete returns false, the primary record isn't deleted and the cascading delete isn't performed. You should first delete the records in the related table before deleting the primary record.
If the primary record is being deleted as part of a cascading delete, the primary record and the records in the related table will be deleted.
Example
The Cascade+Restricted delete action is used in the standard application for LedgerJournalTrans on LedgerJournalTable.
This type of delete action is useful when you prefer a total clean-up—when you delete a customer, you also delete all the transactions associated with that customer.


Types of MAP in dynamics AX


There are two types of Maps available in dynamics AX

1. X++ Maps: it can be used as a temp data store for the given scope of a process. This takes us less over head, and is much quicker than a TempTable. 
2. AOT Maps: A map can unify the access to similar columns and methods that are present in multiple tables. You associate a map field with a field in one or more tables. This enables you to use the same field name to access fields with different names in different tables. Methods on maps enable you to create or modify methods that act on the table fields that the map references. 

Wednesday, 30 January 2013

What is RecID


What is RecId?
The RecId is a unique field in every table, used as an identifier. Every row in the system can be guaranteed (in theory) to have a unique RecId. RecIds can be negative, and their value can change due import/export operations. Due to this, it is not a good idea to use RecIds as foreign key references to other tables.

What is the difference between a RecId and an Id?


The kernel generates the RecId while the Id is generated by the application.