Axaptapedia is now maintained by AgileCadence For more information please click here.

SysRecIdRepair class

From Axaptapedia
Jump to: navigation, search

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 process can be invoked either from the SQL Administration form, or directly from the Application Object Tree by running the class.

The method of interest in the class is mainLoop().

The basic processing is as follows:

  1. Create a new table AXOLDRECIDS to store the existing RecIds in use
  2. For every table, insert all used RecIds from the current company (DataAreaId) into AXOLDRECIDS.
  3. 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.
  4. For each RecId in AXOLDRECIDS, insert a row in AXOLDTONEWRECIDS. This will automatically get a new RecId due to the sequence/identity property.
  5. Create a suitable index on the table to allow fast lookups of the old RecIds
  6. 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.
  7. Update the system sequence with the new highest RecId, for the next time a RecId is requested.