I just had a weird experience and am wondering is it normal or something odd I did.
I was playing with the form for Tariff numbers. I made it a tree by turning it into a temp table form with the SourceTableTemporary property. To populate the table I first do a DELETEALL and then populate it.
This works fine when I run the form.
This does NOT work fine if I click the LOOKUP button on the item card to the new form.
Basically, it seems to ignore the "SourceTableTemporary" property when you use the form as lookup.
This of course means my ACTUAL table got the DELETEALL treatment.
0
Comments
By the way, why would you use a form that's set to use temp records as a lookup form?
RIS Plus, LLC
The deleteall is not the problem. The fact the forum is opened NOT as a temporary form is. If I remove the Deleteall then when i try and populate the table i will get a "Record already exists" type message because I am not populating an empty table but a real one.
Just means I need to recode the lookup by declaring the form as a variable and running it that way.
Still I found it interesting.
Personally I would create a separate form, but that's me.
RIS Plus, LLC
I am referring however to when the form is run from the table, for example if the form is listed in the field "LookupFormID" of a given table.
When run in this fashion Navision ignores the field SourceTableTemporary and runs the form based on the normal live table.
I thought it an interesting fact to highlight on the forum.
As a case example of the DELETEALL. I know that you do not need a DELETEALL on opening the form. It depends how you code it however. Take for a good example form 583 in Nav5 standard. This is based on a temp table. There is a function for InitTempTable() which is called both on opening the form and while using the form. For this reason the code has DELETEALL in this function. This means DELETEALL gets run on opening the form when it is not technically needed.
I copied this idea in my own form and when running the form via a lookup the contents of the REAL table were deleted, not the temp table.
Irritating when forms behave like that, I agree, and thanks for sharing that. I still think creating two separate forms is the way to go personally.
RIS Plus, LLC
We seem to have been talking at cross purposes somehow. This is what I was saying from the start. The form is set to run off a temp record but in this one situation it doesnt do it. I guess its a bug but who knows.
RIS Plus, LLC
ahhhhhhhhhhhh
Me so slow.
It is not a Bug. It is how it works. If the property is set, and you run the form, the Rec is temporary. But if you are running the form through code, and you pass the record to it, the Rec is using the record variable you passed in, and if this variable is not temp, the form will not work with it as temp. And this is the case of lookup form... it means that passing variable to the form "overrides" the setting of Rec variable of the form. It is like the "Temporary" property on function parameter when the parameter is called by ref (var=Yes). In this case the table will be real table or temporary table based on the passed variable, regardless the parameter property...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Now, i put some lines of code in the function to checkc if the table variable is temporary
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog