Viewing Temp tables on Forms

Magno
Member Posts: 168
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.
-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.
0
Comments
-
You can open temporary recods on a form by just
TempItem."No." := 'tada'; TempItem.INSERT; FORM.RUNMODAL(FORM::"Item list",TempItem);
0 -
It depends. Sometimes stuff gets more complicated than that. It's good to check F542, Dimensions Multiple. This is where you can set a dimension and value pair for many f.e. Items at once. There are 3 temp tables in global variables, if I remember correctly, it's TempDefaultDim, TempDefaultDim2, TempDefaultDim3. TempDefaultDim3 contains one entry for each Item you selected - basically a simple saving of your selection. TempDefaultDim2 contains the old dimension code-value pairs of the selected Items. TempDefaultDim is the working table where the users sets the new codes and new values.
It's advisable to check this out. One can learn a lot here.0 -
Freightliner wrote: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).
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.0 -
Hi MTC,
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.0 -
No way I can do that. Customer is using NAV 4SP3.
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.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions