问题
This may seem a simple question, but for some reason I am vexed.
I have a form with 3 datasources - InventTable
, InventSum
, InventDim
.
So, for example, my grid shows;
Item, Name, Site, Warehouse, Physical Stock
I have placed a display method on InventDim
form DataSource, but I need access to the ItemId
from either inventTrans
or InventSum
. (Obviously looking for the "current" itemId).
All I can access is the inventDim
which is passed as a parameter _inventDim
, as standard.
What is the best way to access the "current" itemId?
回答1:
Okay, I found the answer, with great thanks to this reference by Joris de Gruyter;
http://daxmusings.blogspot.co.uk/2011/10/forum-advanced-display-method-querying.html
The key was to put the display method on the InventSum
datasource.
You can then use _inventSum.joinChild()
to retrieve the linked inventDim
, here is Joris' example;
display Qty AvailPhysical(InventSum _inventSum)
{
InventDim joinDim, dimValues;
InventDimParm dimParm;
InventSum localSum;
//THE IMPORTANT LINE...
dimValues.data(_inventSum.joinChild());
dimParm.initFromInventDim(dimValues);
select sum(AvailPhysical) from localSum where localSum.ItemId == _inventSum.ItemId
#InventDimExistsJoin(localSum.InventDimId, joinDim, dimValues, dimParm);
return localSum.AvailPhysical;
}
I am sure this will help someone out in the future!
来源:https://stackoverflow.com/questions/11452892/display-methods-multiple-form-data-sources