Hi,
This question is specially for the persons who have worked to build the AX kernel or have access to it's code.
My AX version: AX 2012 R2 CU7 (both app and kernel)
I had few custom tables which were in ISV layer before and later, for some reason, were moved to VAR layer. The procedure adopted was
1. Create a separate new database and create the replica of custom tables in this database.
2. Copy all data of custom tables from AX business DB to this new database.
3. Delete the model (with elements in ISV layer). Compile, synch, CIL etc. This deleted the custom tables in AX business DB.
4. Import the model in VAR layer (this model have same elements but in VAR layer). Compile, synch, CIL etc. All the tables are again created in AX business DB.
5. Stop AOS. Get the data back into custom tables from new database to AX business DB.
6. Run a SQL script to update the 'SYSTEMSEQUENCES' table for each custom table record with following logic
'NextVal' field value = (Existing largest recid for the table) + 1.
7. Start the AOS.
During normal operation, the custom tables' randomly gives the error - 'Record already exist' even when no unique index is violated by data. Looking back at the specific table's record in 'SYSTEMSEQUENCES' table in SQL, the value of 'NextVal' field has gone back to one of the existing recid.
Now this is a mystery to me how system is actually assigning recids to new records in table. All I know is a stored procedure which increments the recid to provide next recid. But I guess there is some more logic in kernel which caches the recid and manipulates the value in 'NextVal' field of 'SYSTEMSEQUENCES' table record.
AX Kernel Experts - Please help me out. What should be done to fix the issue?
I have also tried executing the methods of 'SystemSeuqence' class for all the custom tables to make recids in order but no luck.
Any help will be appreciated.
Regards,
Deepak
*This post is locked for comments