There is a new Record ID in town

In Dynamics AX 4.0 the record ID has changed base datatype from an integer to a 64-bit integer and the ID is now issued on a table by table basis. This obviously solves the problem of installations running out of record ID's, but it may also introduce a bit of work on your old solutions if you have code that depends on record ID's.

Since the datatype is now changed your code maybe fail in the places where you expect the record ID to be the old 32-bit integer. So you need to work your way through the following refactorings:

  1. Everywhere that fields of a type deriving from the 64-bit integer is assigned to a 32-bit integer value, the assigned value must be rewritten as a variable of the same type, or explicitly cast into a 32-bit integer. For example:

    int recId = common.recId;

    must be rewritten as:

    RecId recId = common.recId;

  2. Everywhere a variable deriving from RecId is used as an index to an array, the code must refactored to use a map or a temporary table. For example:

    int array[,1];
    array[common.recId] = 123;

    must be rewritten as a map (in memory - can be used for few records)

    Map map = new Map(TypeId2Type(TypeId(RecId)), Types::Integer);
    map.insert(table.recId, 123)

    or a temporary table (on disk - can be used for many records)

    TmpTable tmp;
    tmp.recIdRef = table.recId;
    tmp.value = 123;
    tmp.insert;

    (Tip: The class SysTmpRecIdMap allows you to use a temporary table with the methods you would expect from a Map)

  3. Everywhere that variables deriving from RecId are placed into collection objects, the code must be updated to create the objects with the right type. For example:

    Set set = new Set(Types::Integer);
    set.insert(common.recId);

    must be rewitten as:

    Set set = new Set(TypeId2Type(TypeId(Recid)));
    set.insert(common.recId);

Table relations that are dependant on record ID's might need to have the table ID added to the relations, since the record ID is no longer unique accross tables. Take for example a look at the Address table.

This posting is provided "AS IS" with no warranties, and confers no rights.