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.
0
Comments
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": "OnNextRecord":
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
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 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??
Benny Giebens
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).
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!
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>
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com
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.