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
; —————————————————————————
  TABLEVERSION 1
 
  TABLE #PriceDiscTable
    EnforceFKRelation 0
    PROPERTIES
      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

Advertisements

Über erpcoder
Software Engineer and Dynamics AX 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:

    Hi,

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

    Regards
    Arun

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s

%d Bloggern gefällt das: