Hi,
I would like to know how should a table relation between table saved per company and table not saved per company be defined correctly in AX 2012. Please find below 2 cases I made.
Case 1.
Use dataAreaId in table relation
1.1 Create a new table TestSystemTable (SaveDataPerCompany
= No).
1.2 Add 2 foreign keys from DlvMode (SaveDataPerCompany = Yes)
and Hierarchy (SaveDatePerCompany = Yes) tables, plus add dataAreaId fields (use AgreementHeaderDefault table as an example in standard AX)
1.3 Add table relations (as I want to filter records of Hierarchy table I define a relation with
“related field fixed”, actually like it is in CaseDetailBase table) :
1.4 Create a new record in table browser, open HierarchyId field lookup –> no record, however a record exists in Hierarchy table (for example in CEU company):

1.5 Create a record in Hierarchy table in DAT company, repeat step 1.4 -> the record is presented in lookup.
So for some
reason the relation between TestSystemTable and Hierarchy tables is built based on DAT dataAreaId, but not the current company or dataAreaId field specified in
the table relation. Why?
Case2.
Do not use dataAreaId in table relation
2.1 Duplicate TestSystemTable and name it TestSystemTable2
2.2 Remove dataAreaId from Hierarchy table relation:

2.3 Lookup works correctly:

However from the logical point of view the relation is wrong as dataAreaId is not
used.
It can be
somehow connected to relations on EDT:
I’m out of
ideas, but I think it is quite important to understand how table relations must
be defined.
Thank you for feedback.