Dynamics AX Data Upgrade : Valid Time State Key Error after Upgrading or Updating
Some times during Upgrades we face a compilation error “Table does not contain a valid time state key. A unique index needs to be marked as a valid time state key.”
Reference:
https://community.dynamics.com/ax/b/elandaxdynamicsaxupgradesanddevelopment/archive/2015/02/12/valid-time-state-key-error-after-upgrading-or-updating
Cause
The index is disabled using indexAllowDup method, then properties AlternateKey and ValidTimeStateKey are reset to default value No.
ReleaseUpdateDB::indexAllowDup(new DictIndex(tableNum(TableName),
indexNum(TableName, DateEffectiveIndex)));
The error starts to show up then indexes are not enabled correctly using methodindexAllowNoDup:
ReleaseUpdateDB::indexAllowNoDup(new DictIndex(tableNum(TableName),
indexNum(TableName, DateEffectiveIndex)));
AlternateKey and ValidTimeStateKey properties are not set using the code and then you start getting compilation error mentioned above.
Solution
You should use the method indexAllowNoDupAndDateEffective instead:
ReleaseUpdateDB::indexAllowNoDupAndDateEffective(new DictIndex(tableNum(TableName),
indexNum(TableName, DateEffectiveIndex)), ValidTimeStateMode::Gap or NoGap);
Sometimes you can see the following code, but that is implemented in indexAllowNoDupAndDateEffective method:
DictIndex dictIndex = newDictIndex(tableNum(TableName),
indexNum(TableName, DateEffectiveIndex));
dictIndex.modify(true, false, true);
dictIndex.setAlternateKey(true, true);
dictIndex.setValidTimeStateKey(true, ValidTimeStateMode::Gap or NoGap, true);
appl.dbSynchronize(dictIndex.tableid(), false);
Reference:
https://community.dynamics.com/ax/b/elandaxdynamicsaxupgradesanddevelopment/archive/2015/02/12/valid-time-state-key-error-after-upgrading-or-updating
Comments
Post a Comment