SurrogateKey on imported tables

If a new table is created in Dynamics AX 2012, its primary and cluster indexes are automatically set to “SurrogateKey” value. But if you import a table from an older version, SurrogateKey is not available and I’ve found no “normal” way how to achieve this.

Nevertheless… in the .xpo of the newly created table:

TABLE #Table1
    EnforceFKRelation 1
    PROPERTIES
      Name                #Table1
      CreateRecIdIndex    #Yes
      PrimaryIndex        #SurrogateKey
      ClusterIndex        #SurrogateKey
      Origin              #{A948828D-E7B9-42BD-A619-6305867AF2CE}
    ENDPROPERTIES

an item called EnforceFKRelation can be found and it is apparently responsible for this behavior. Its value can be changed in .xpo and the .xpo can be imported back to AX.

You can read this value in Dynamics AX from DictTable.enforceRelationRules() and cross-references show that it also activates some additional validations in Best Practice check.

4 Comments

  1. Yep, ran into this one yesterday: this ‘enforceFKRelation’ is with BP Error 839 ‘Only foreign key constrains are allowed on this table’. Check the sysBPCheckTable.checkRelations method, at line 230 you see the line ‘if(sysDictTable.enforceRelationRules())’. Does anyone know why this ‘enforceFKRelation’ entry exists in an xpo? Or hy this cannot be seen or changed in Ax? Or why some tables return ‘false’ and others ‘true’ (it seems any newly created table return ‘true’, the ones created by MS sometimes return ‘false’)? Any extra info on this one would be enlightening.

  2. Hello Martin,

    Changing the value in the Xpo and impoting the Xpo doesn’t work. Do you have another solution?

    Best regards

    • Could you be a bit more specific? What did you do and what is the resulting behavior?

Comments are closed.