SourceTableTemporary forms with DELETEALL

MauddibMauddib Member Posts: 269
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.

Comments

  • DenSterDenSter Member Posts: 8,307
    If the DELETEALL is in OnOpenForm, then you don't need it. When the form opens with a temp record, that temp reconrd doesn't have any values yet. comment out that statement and see what happens.

    By the way, why would you use a form that's set to use temp records as a lookup form?
  • MauddibMauddib Member Posts: 269
    As I said I took the Tarriff form and made it an expandable tree form. I needed to make it a temporary form to do this.

    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.
  • DenSterDenSter Member Posts: 8,307
    Then the form is not based on a temporary record, or what is displayed is a variable other than what the form is based on. When you create a temporary variable, it is empty. You don't have to delete anything from a temporary table that is empty.

    Personally I would create a separate form, but that's me.
  • MauddibMauddib Member Posts: 269
    The form IS based on temporary. SourceTableTemporary IS yet to yes and when I RUN the form it acts as expected.

    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.
  • DenSterDenSter Member Posts: 8,307
    Mauddib wrote:
    When run in this fashion Navision ignores the field SourceTableTemporary and runs the form based on the normal live table.
    So I was right, and the form does NOT run with a temporary record :mrgreen:

    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.
  • MauddibMauddib Member Posts: 269
    DenSter wrote:
    So I was right, and the form does NOT run with a temporary record :mrgreen:

    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.
  • DenSterDenSter Member Posts: 8,307
    Mauddib wrote:
    We seem to have been talking at cross purposes somehow. This is what I was saying from the start.
    You're right you were, and I was missing that somehow, and with the :mrgreen: I was trying to make light of that.
  • MauddibMauddib Member Posts: 269
    DenSter wrote:
    Mauddib wrote:
    We seem to have been talking at cross purposes somehow. This is what I was saying from the start.
    You're right you were, and I was missing that somehow, and with the :mrgreen: I was trying to make light of that.

    ahhhhhhhhhhhh

    Me so slow.
  • kinekine Member Posts: 12,562
    Mauddib wrote:
    DenSter wrote:
    So I was right, and the form does NOT run with a temporary record :mrgreen:

    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.

    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... :wink:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • BeliasBelias Member Posts: 2,998
    Kine wrote:
    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... :wink:
    I just doomed a table in development environment for this. ](*,) ](*,) ](*,)
    Now, i put some lines of code in the function to checkc if the table variable is temporary
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.