[Newbie question] Form with temporary table

ferris
Member Posts: 23
I have a stupid problem.
I want to open a form (from menu) based on a temporary table.
I have create a C/AL global variabile myVar::Record and, in the form properties:
- SourceTablePlacement: Record
- SourceTableRecord: myVar (or the id, but is the same)
But I receive an error.
The sourceTable must be set?
Thanks very much.
I want to open a form (from menu) based on a temporary table.
I have create a C/AL global variabile myVar::Record and, in the form properties:
- SourceTablePlacement: Record
- SourceTableRecord: myVar (or the id, but is the same)
But I receive an error.
The sourceTable must be set?
Thanks very much.
0
Comments
-
Create a form that works on the real table.
To use the form with a temptable, you can do it in 2 ways:
1) FORM.RUNMODAL(FORM::"The Form",tmpTheTempTable); // "tmpTheTempTable" is the temptable
2) put some code in some triggers:
"OnFindRecord":tmp17.COPY(Rec); blnFound := tmp17.FIND(Which); Rec := tmp17; EXIT(blnFound);
"OnNextRecord":tmp17.COPY(Rec); intResultSteps := tmp17.NEXT(Steps); Rec := tmp17; EXIT(intResultSteps);
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
The first part of kriki answer is right, but the form is temporary only if called that way. For the second I don't Know but you shouldn't set the rec to the temporary table if you don't find it. So better "don't move". Subsequently:
Form - OnFindRecord(Which : Text[1024]) : Boolean
tmpTable.COPY(Rec);
IF NOT tmpTable.FIND(Which) THEN
EXIT(FALSE);
Rec := tmpTable;
EXIT(TRUE);
Form - OnNextRecord(Steps : Integer) : Integer
tmpTable.COPYFILTERS(Rec);
LintCurrentSteps := tmpTable.NEXT(Steps);
IF LintCurrentSteps <> 0 THEN
Rec := tmpTable;
EXIT(LintCurrentSteps);
I tried this code a lot of times. It works well.
If you decide for the second way you must be careful with the OnInsertRecord, OnModifyRecord, OnDeleteRecord of the form. The form must be not editable or if editable you must write code to avoid inserting record on "true table". You can handle that via this code:
Form - OnModifyRecord() : Boolean
tmpTable := Rec;
tmpTable.MODIFY;
EXIT(FALSE);
The same for Delete or Insert.
Remember you must modify,delete,insert the temporary table that is set has global variable on that form, and not the rec!
To Kriki: remember.... my subject! :-)I don't envy anybody who caught up his aim. I travel gladly.0 -
Thanks very much!0
-
What doi you have to put on the omdeleterecord section?
I tried different ways , but none of them seems to work
tmpTable := Rec;
tmpTable.delete;
EXIT(FALSE);
tried exit(true);
tried currform.update(false);
any ideas in what should work to delete one record in the form??Rgds
Benny Giebens0 -
At first a little correction (wrong using of copy/paste):
Form - OnNextRecord(Steps : Integer) : Integer
tmpTable.COPY(Rec); //not copyfilters
LintCurrentSteps := tmpTable.NEXT(Steps);
IF LintCurrentSteps <> 0 THEN
Rec := tmpTable;
EXIT(LintCurrentSteps);
BGI: On Ondelete you must write what you tried first:
tmpTable := Rec;
tmpTable.delete;
EXIT(FALSE);
Probably you wrote wrong code on other triggers (if it's OnNextRecord you now have the solution).I don't envy anybody who caught up his aim. I travel gladly.0 -
Hi!
what about just filling out an recordvairable that is set to Temporary(yes).
only to be used if the amount of records is not to hughe, then the loop will
take some time..
if myrec.find('-') then begin
repeat
tmprec.init;
//populate the fields here.
tmprec.insert;
until myrec.next = 0;
form.runmodal(Number,Tmprec);
end;
Now u can even use filters and so on!
May the force be with u!0 -
ObiWan wrote:Hi!
what about just filling out an recordvairable that is set to Temporary(yes).
only to be used if the amount of records is not to hughe, then the loop will
take some time..
have a look at the code from the posting and the content. ](*,)
1. The form must have a record.
2. if the form is editable, and the user edits or deletes the form record then you get an "Error".
In the scenario's above you load the temp record, present this to the user, who can edit and delete records, then you can take the recordset back and process it, cool or what??! =D>Analyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
Moreover, this method will create a "stand alone" form based on a temporary table. This means that, no matter the way you call it, it's based on a temporary table and not on the database table.
And as a consequence, you can create "document form" (meaning form with subform) based on a temporary table and a dependent temporary table.
That can't be done with form.runmodal(formNo,temptable), because there's no way to call the subform that way. There's some work to do to mantain the "Header/Line" relation.... but it's possible (and I'm doing it for a customer).
Really not a standard Navision programming... It's a kind of different "software architecture" for which no changes are made on the database until the user or a "saving on OnTimer" decides for it. So the system can process more record at once, or other things like that. As a different "software architecture", it's not the right answer to every question.... only a different way that can be considered. And, obviously, being all records on Ram... it has good performance.I don't envy anybody who caught up his aim. I travel gladly.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