I am testing on how to bring a new field from another table into a form, using a method.
display ItemName testme2()
return (select firstonly ItemName from inventTable
index hint ItemIdx
where inventTable.ItemId == PCT.Key1).ItemName;
There are no errors or warnings returned when compiled. Although the same query works in another method, the one above returns no values.
Any ideas why?
You never set PCT variable, therefore PCT.Key1 is empty and the query tries to find InventTable without ItemId, which can't succeed because ItemId is mandatory.You should probably place the method on ProdCalcTrans table and find InventTable by this.Key1.
Martin "Goshoom" Dráb | Freelancer | Goshoom.NET Dev Blog
I have it in ProdCalcTrans table. Key1 is a field from ProdCalcTrans and PCT is defined above. Sorry you got me a bit confused. Would you be able to give me an example?
I see that's PCT is defined above and never assigned, that's exactly the problem. You would have to assign a value to the variable (select statement, find() method or so) to get that code working. But if you want to Key1 of the current ProdCalcTrans record, remove PCT variable completely and just use where inventTable.ItemId == this.Key1.
Any idea why the following code would work?
display ItemName itemResourceName()
select firstonly ItemName from inventTable
index hint ItemIdx
where inventTable.ItemId == prodCT.Key1;
select firstonly Name from wrkCtrTable
index hint WrkCtrNumIdx
where wrkCtrTable.WrkCtrId == prodCT.Key1;
select firstonly Description from costSheetNodeTable
where costSheetNodeTable.Code == prodCT.Key1
&& costSheetNodeTable.SheetId == CostSheetTable::defaultCostSheetTable().SheetId;
Did not work replacing with this.Key1. No errors/warnings but also nothing returned.
Use debugger to see whether your method is call in the first place, what value it in PCT.Key1/this.Key1 and what the select returns. Identify what doesn't work as you expect and if you fail to figure out what's wrong, return back here and tell us all relevant details.
I will install debugger on one of the aos's. In the meantime I used a print statement to view result and it returns blank. I will come back after debugger is installed. Thanks
I started from the beginning and both versions of the method are working. Not sure what was wrong. Didn't even get to run the debugger although now I have it setup for next time.