I will be covering the Date Effective Framework that has come with the newer version of Ax i.e. Ax2012.I have broken the the artifacts of the framework in four parts.
Here is the list:
- Create DateEffective table
- Create DateEffective Form
- Examples of DateEffective records(CreateNewTimePeriod,Correction and Effective Based mode)
- How to Query DateEffective records
In this part, I will be creating the DateEffective table
So let start with the introduction
What is DateEffective Framework?
Think of a scenario where company wants to keep track of things like if the company maintains the employee position over the years ,or a government wants to keep track of the Oil prices or want to keep track of Currency values over the period of time so it means the items like oil,currency or employee position should be date effective.In Ax 2012 to provide this functionality for the users ‘DateEffective Framework’ comes in.Microsoft Dynamics AX 2012 offers the date effective functionality to provide the ease, consistency, and scalable behavior of application code for date effective scenarios.
Now I am quickly jumping to the creation of DateEffective table
Creation of DateEffective table or Valid Time State table
Here i am covering the scenario of Currency to be date effective
I have created a new table with the name ‘AsimDateEffectiveTable’ with the fields
- Currency of type string
- Price of type integer
Now to make it DateEffective/ValidTimeState table i need to set the ‘ValidTimeStateFieldType’ property like
So i have selected the Date option just to make things simple,after saving the table and error comes in
So the error saying is,the table should have a unique index to be a date effective table,so here is the solution
I have created an Index with the name CurrencyIdx containing fields Currency ,validFrom,validTo.
Reason for the Idx fields
- Currency field is our mandatory field
- ValidFrom should be use to make the idx unique.So the combination of Currency and ValidFrom makes a unique record.
- ValidTo may be or may not be use,but it is a best practice to use it on creating new tables
set properties of the index to :
Here i have set:
- AllowDuplicates = No
- AlternateKey = Yes
- ValidTimeStateKey = Yes
- ValidTimeStateMode = NoGap(so there will be no gap between versions of the same record)
So on compiling the table the error would be gone .Now the table as a unique index
Last thing we would be doing is to placing this index as a replacement key of a table like :
Now just save the table and we have created our dateEffective/ValidTimeState Table we would be something like this
I have added some data records here.
Please let me know for queries