Axaptapedia is now maintained by AgileCadence For more information please click here.
The SysRecIdRepair class is used to correct RecId problems within Axapta, and to remove the gaps in the used RecId sequence so that the limit of available RecIds is not reached prematurely.
The method of interest in the class is mainLoop().
The basic processing is as follows:
- Create a new table AXOLDRECIDS to store the existing RecIds in use
- For every table, insert all used RecIds from the current company (DataAreaId) into AXOLDRECIDS.
- Create a new table AXOLDTONEWRECIDS to store a mapping between the old and new RecIds. The NEWRECID field will have the IDENTITY flag set for SQL Server, or a SEQUENCE will be created in Oracle, to automatically create a new value for NEWRECID when a record is inserted.
- For each RecId in AXOLDRECIDS, insert a row in AXOLDTONEWRECIDS. This will automatically get a new RecId due to the sequence/identity property.
- Create a suitable index on the table to allow fast lookups of the old RecIds
- For every table, update the RecId field by looking up the old RecId from AXOLDTONEWRECIDS.OLDRECID and replacing it with the value from AXOLDTONEWRECIDS.NEWRECID.
- Update the system sequence with the new highest RecId, for the next time a RecId is requested.