For example we need to tie following datasources:
InventSum
InventDim
InventBatch
InventBatch unique key index consists of ItemId and InventbatchId, therefore we need to link Invnetbatch with both InventDim and InventSum. However, if you try to do it using addLink method:
qbdsInventBatch.clearDynalinks();
qbdsInventBatch.addLink(fieldnum(InventDim, inventBatchId), fieldNum(InventBatch, inventBatchId));
qbdsInventBatch.addLink(fieldnum(InventSum, ItemId), fieldNum(InventBatch, ItemId));
Invalid Field/Related field combination":
There are a few tricks how this can be resolved:
1. Create a view from InventSum and InventDim and use it as a single data source and then join InventBatch to it.
2. Start query from Inventbatch data source and then join to it InventSum and InventDim. However, considering the example above in most cases it will not be logical. But it might work in your case.
3. Use extended ranges. The solution will have the following look:
QueryBuildRange qbrItemId = SysQuery::findOrCreateRange(qbdsInventBatch, fieldNum(InventBatch, ItemId));
str itemIdRange = strFmt('(%1.%2=%3.%4)', qbdsInventBatch.name(), fieldStr(InventBatch, ItemId), _inventSum_DS_Query.dataSourceName(formDataSourceStr(InventOnhandItem, InventSum)).name(), fieldStr(InventSum, ItemId));
qbrItemId.value(itemIdRange);
Additional query build extended range example
( 1
min )