1. WORKING:
2. NOT WORKING: (name is empty)
sysTableLookup.addLookupfield( fieldNum(EngChgProductCategoryDetails, RecId), true);
sysTableLookup.addLookupMethod(tableMethodStr(EngChgProductCategoryDetails, name));
For both situations I did include the category table in my query. I literally copied the form controls and this is the only difference to get it working. In the WORKING case all 3 fields show data. In the not working case only the recid column shows data.
Now lets try removing the lookupMethod then since I see the same data twice:
3. ALSO WORKING:
sysTableLookup.addLookupfield( fieldNum(EngChgProductCategoryDetails, RecId), true);
sysTableLookup.addLookupfield( fieldNum(EngChgProductCategoryDetails, Category));
This is actually working, despite the category field being of type refrec pointing to the category...
So the following code is correctly showing me the category value, while the category table is NOT in the query and NOT in the lookup:
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildDataSource qbdsJoin;
SysTableLookup sysTableLookup = sysTableLookup::newParameters( tableNum(EngChgProductCategoryDetails), this);
qbds = query.addDataSource( tableNum(EngChgProductCategoryDetails));
sysTableLookup.parmQuery(query);
sysTableLookup.addLookupfield( fieldNum(EngChgProductCategoryDetails, RecId), true);
sysTableLookup.addLookupfield( fieldNum(EngChgProductCategoryDetails, Category));
sysTableLookup.performFormLookup();
Is this simply because the compiler understands that when I mention a field of refrec type that he understands I want the data from the table it points to?
Either way, I will mark your answer as solution Martin, because I got it working. (and otherwise would via a view as well)