Hello,
I have a simple form where it has a table (In Memory) as a datasource.
On page load, I m filling this table from data coming from web services on the fly.
Once page gets loaded, User adds a new record in it. For each line user adds, i want to assign the new Line num which would be in addition to the max linenum out of the record i got from the web service records.
Hence in Initvalue() method of table, I am trying to find the max linenum from the existing record but I always get 0 records. not sure why. User could see the records came from the web service on the form. They can add the new record as well but LineNum is not getting set correctly for these new records. ALL newly added records gets LineNum=1 because it thinks that there is no any record in the table.
Table's initvalue method is shown below.
public void initValue()
{
MyTempTable tmp;
super();
select maxOf(LineNum) from tmp;
this.LineNum = tmp.LineNum +1;
}
Can someone help to identify what's missing?
*This post is locked for comments
Instead of writing code in initvalue() of table, i wrote it on initvalue() of form datasource and it worked. I wrote it before super() call in it.
public void initValue()
{
MyTempTable tmp;
tmp.settmpData(MyTempTable); // Here MyTempTable is a datasource.
select maxOf(LineNum) from tmp;
this.LineNum = tmp.LineNum +1;
super();
}
setTmpData should actually work, could you please share your code, so we can advise if something wrong there.
I already tried this but somehow forgot to mention in my question. Sorry that doesn't work.
Temporary tables, both memory and tempdb, are not backed by single instance table like regular AOT tables. With regular AOT tables, like CustTable, when you declare a variable of type CustTable, it is ultimately backed by the same physical database table. You can select and filter on your variable, creating a result set (or subset), and move next and such, acting as a cursor, but all variables of type CustTable share a common backing table.
Each time you instance a temporary table, as you have done in your declarations in initValue(), it is backed by a separate data set. So in your initValue() method when you declare MyTempTable tmp; that is not the same backing table as the record referenced by "this".
Fortunately, you can connect your new variable to the backing table of "this". I believe the following line works (it is different for in memory and tempdb tables).
tmp.setTmpData(this);
Hope this helps.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,219 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156