Get rid of BP:839 Only foreign key constraints are allowed on this table

If your create a conditional relation including a fixed field and normal relation you will get a best practice error 839 telling you Only foreign key constraints are allowed on this table.

Dynamics Ax 2012 Best Practice Error 839

However such relations are used e.g. in the PriceDiscTable where no such BP:829 error is show. The table compiles without any best practice errors.

No Best Practice Error 839 in PriceDiscTable

Exporting both tables to an XPO and comparing them reveals that a there is a flag EnforceFKRelation which is set to 0 at the PriceDiscTable and 1 to all other newly created tables in Dynamics AX.

Comparing PriceDiscTable XPO

However, you cannot set this flag in the property dialog in AX. As it is not a property of the table itself, it does not even appear in the TreeNode.AOTgetProperties() list.

Exportfile for AOT version 1.0 or later
Formatversion: 1

***Element: DBT

; Microsoft Dynamics AX Table : PriceDiscTable unloaded
; —————————————————————————
  TABLE #PriceDiscTable
    EnforceFKRelation 0
      Name                #PriceDiscTable
      Label               #@SYS5926

As Martin already posted, this issue can be addressed changing the value by hand in the XPO. However, this approach works only if the modified table was deleted before (re-)importing it to the AOT. Use the SQL Server Export / Import Data Tool to save your data e.g. to a flat file and import it afterwards. Moreover, if the flag is set to 0 in the XPO it is also advised not to use SurrogateKeys as Primary Key and Cluster Key anymore. Otherwise you will get minor import errors.

BP Error 839 is gone

About erpcoder
Azure Cloud Architect and Dynamics 365 enthusiast working in Research & Development for InsideAx

One Response to Get rid of BP:839 Only foreign key constraints are allowed on this table

  1. Arun Garg says:


    Is there any other solution available for new table relation with existing table like InventTable or InventLocation Table.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: