Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display Methods - Multiple Form Data Sources

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?

like image 642
AnthonyBlake Avatar asked Feb 20 '23 21:02

AnthonyBlake


1 Answers

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!

like image 129
AnthonyBlake Avatar answered May 14 '23 10:05

AnthonyBlake