This generate SQL with relations on DataAreaId between tables. Is possible to disable this relations?
SELECT A.PURCHID, A.DATAAREAID, A.RECID
FROM PURCHTABLE A
WHERE ((A.DATAAREAID IN (?,?) )
AND ((A.DATAAREAID=?)
AND (A.PURCHID=?)))
AND EXISTS
( SELECT ‘x’
FROM SALESTABLE B
WHERE ((B.DATAAREAID IN (?,?) )
AND ((B.DATAAREAID=A.INTERCOMPANYCOMPANYID
AND (B.DATAAREAID = A.DATAAREAID))
AND (B.SALESID=A.INTERCOMPANYSALESID
AND (B.DATAAREAID = A.DATAAREAID)))))
Even though this problem may not be relevant to you any longer, but I will post a reply which may be beneficial to someone else.
I was also struggling with the same issue: the kernel was adding the (B.DATAAREAID = A.DATAAREAID) clause automatically if it detected a join by some fields between those tables. In your case it is
salesTable.SalesId == purchTable.InterCompanySalesId that causes the problem.
If you would change this line to something like salesTable.SalesId == ‘SO-00001’, the kernel would not add the (B.DATAAREAID = A.DATAAREAID) clause and the query would return (some) result.
This discovery lead me to the following workaround: it is possible to “fool” the kernel by changing your select statement in the following way:
salesTable.SalesId == purchTable.InterCompanySalesId+’’.
Yay!!!
Now I wish I could figure out a workaround for the same problem in a Query…
Notice the %3.%4+"" part in expression which does the trick. Kernel query engine ‘thinks’ that is not a join, but a complex expression and doesn’t bother with it
Same technique can be used if you want to filter by DataAreaId field and avoid the “Filtering at the data source level is not allowed for a cross-company query.” error message.