Let me get this straight with description of what I am doing step-by-step.
1. I open AX 2012 and create a query in AOT/Queries
2. Add TSTimesheetLine as a first root datasource
3. In TSTimesheetLine’s datasources node I create a new one that references to ProjTable.
Both of the tables have SaveDataPerCompany property as Yes.
4. After that I add two new relation to ProjTable datasource:
TSTimesheetLine.ProjId == ProjTable.ProjId
and
TSTimesheetLine.ProjectDataAreaId == ProjTable.DataAreaId
As I want to find a project in the company it exists (even when TSTimesheetLine.ProjectDataAreaId is not equal to TSTimesheetLine.DataAreaId)
5. After that I go to AOT/Data Dictionary/Views and create a new view
6. Add the created query to view as its datasource and add new fields in Fields node to be selected.
7. But I do not have expected result. The project record is NULL where TSTimesheetLine.ProjectDataAreaId is not equal to TSTimesheetLine.DataAreaId.
8. After that I go to SQL Server Management Studio, look for this view and look at the join that it has.
The joins look like (simplified):
TSTimesheetLine.ProjId == ProjTable.ProjId AND TSTimesheetLine.ProjectDataAreaId == ProjTable.DataAreaId AND TSTimesheetLine.DataAreaId == ProjTable.DataAreaId AND TSTimesheetLine.Partition == ProjTable. Partition
The key point is here:
TSTimesheetLine.ProjectDataAreaId == ProjTable.DataAreaId AND TSTimesheetLine.DataAreaId == ProjTable.DataAreaId
These two relations filter each other so I do not have such records.
This TSTimesheetLine.ProjectDataAreaId == ProjTable.DataAreaId is a relation added by me.
This TSTimesheetLine.DataAreaId == ProjTable.DataAreaId is a relation added by AX Kernel to resolve two SaveDataPerCompany=Yes tables.
So, the main question was: Can I somehow leave only this one:
TSTimesheetLine.ProjectDataAreaId == ProjTable.DataAreaId
And avoid adding this one:
TSTimesheetLine.DataAreaId == ProjTable.DataAreaId
Hope this is more clear.
Thanks for your help here.