Warning: Creating default object from empty value in C:\xampp\htdocs\maziktech\wp-content\themes\salient\nectar\redux-framework\ReduxCore\inc\class.redux_filesystem.php on line 29
Simple use of Unit of Work in Microsoft Dynamics AX 2012 - Mazik Tech Solutions

Overview
The main purpose to use Unit of Work (UOW) is to maintain the referential integrity. At a certain point of time application doesn’t want to be in a situation where violation of referential integrity occurs: for example for the records to be inserted and deleted; sequence should be maintain like Parent record should be inserted first and then the child record, and on deleting the record child should come first prior to parent. When we talk about programmatically maintain this, it is a quite big asks when we are dealing with more normalized data in Dynamics AX 2012.So to cater this “Microsoft Dynamics Ax 2012” provided the “UnitOfWork” programming concept which overcome this and maintain the referential integrity throughout the application.
Some key points relating to UOW:

  • It is basically a collection of operations(like CRUD) that are performed sequentially and as a Unit
  • “Application code establishes relation between data in memory, modifies data, registers the operation request with the UOW framework,and then request the UOW perform all the registered operation in the database as a unit.”
  • UOW always run on server

Simple Example:
In the below snapshot I have create two tables PurchHeader and PurchLines and a Foreign key relation on the child table PurchLines. You can also see the field for each table


I have also set the “Create Navigation Property Methods” to Yes.
uw2
  • Facebook
  • LinkedIn
  • Twitter

Create Navigation Property Methods:

  • This property is only available for foreign key relation
  • When set to YES, it makes the kernel-generated methods on a table buffer to be created.
  • We can  use these methods to set, retrieve and navigate to the related table buffer through the specified relation.

As I mentioned above,UOW can always be used on server,so I have written a class to perform the operation,please also read the comments I have added.


After that when you open the PurchHeader and PurchLines table you will see the records have been created like
uw4
  • Facebook
  • LinkedIn
  • Twitter

 

Leave a Reply

PHP Code Snippets Powered By : XYZScripts.com