Everybody has already stumbled against the problem of viewing temp tables in forms used for viewing, not for adding or deleting(however this is possible too).
-First you set the sourcetable to the same ID as the temp table.
-on OpenForm or wherever(like push on button) fill the temp table.(PUT A RESET AFTER FILLING IT!!)
OnFindRecord(Which : Text[1024]) : Boolean
<Temp table>.COPY(Rec);
IF NOT <Temp table>.FIND(Which) THEN
EXIT(FALSE);
Rec := <Temp table>;
EXIT(TRUE);
__________________________
OnNextRecord(Steps : Integer) : Integer
//MAKE A LOCAL INTEGER liCurrentSteps
<Temp Table>.COPY(Rec);
liCurrentSteps := <Temp Table>.NEXT(Steps);
IF liCurrentSteps <> 0 THEN
Rec := <Temp Table>;
EXIT( liCurrentSteps);
Probably many of you will have used something similar, the copy line is one I added, this line makes sure you can even use filters,keys,... on the lines.
There are no bugs, only random undocumented features...
---
My Blog:
http://NAV-Magno.be0
Comments
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
It's advisable to check this out. One can learn a lot here.
Yes, you have to add:
Form - OnInsertRecord(BelowxRec : Boolean) : Boolean
<Temp Table>.COPY(Rec);
<Temp Table>.INSERT;
EXIT(FALSE);
Form - OnModifyRecord() : Boolean
<Temp Table>.COPY(Rec);
<Temp Table>.MODIFY;
EXIT(FALSE);
Form - OnDeleteRecord() : Boolean
<Temp Table>.COPY(Rec);
<Temp Table>.DELETE;
EXIT(FALSE);
For inserting, you will still have to deal with the value of the primary key, remembering that AutoIncrement doesn't work on temporary tables.
Thank you. This coding snippet is really a life saver. I was looking and trying so hard on getting nav forms to display and allow edit and insert to temp tables.
Thanks.
Mark explained it once in one of his blog posts. You can find it here.
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
After doing the development half way through... i realised that the table is a main form, sub form relation. This makes implementing this using a temp source table much more complicated now...
Actually, what i wanted to achieve with temp table, is so that a user can make changes to a setup table (as much as they like), and commit the changes (and run some update processes here...) when the user leaves the form.
I cannot put the update processes in the Onvalidate trigger (or any record related triggers...) as the update processes are very taxing to the system.