CurrForm.UPDATE Query

kash387kash387 Member Posts: 111
Hello everyone,

I have one form, in which I have put some filter OnOpenForm trigger,
say like, (Rec.)SETRANGE(Boolean,False);

It will show me only records that are false while opening the form.
Then I have one button, which is having code that makes the Boolean field true based on few conditions. The Code ends with,

RecVar.Modify;
CurrForm.UPDATE(FALSE)

The problem is, when the boolean field becomes true and form gets updated, the record will be removed from the form.

Can anyone tell me how I can keep it on the form, after updating the form????

Thanks and Regards,

Kashyap
Thanks,

Kashyap

Answers

  • BeliasBelias Member Posts: 2,998
    First (most important): why do you need it?
    second: if possible, don't modify the rec, instead modify a rec variable of the same type.

    third (answer): you can't (without personalization)!what did you expect? the record has gone out of the filter range if you modify the filtering field!as you're modifying a field used for filtering, this can cause a so called "next from hell", be careful (follow the second point ot avoid this).

    fourth: Actually there's a way to solve your problem: base the form on a temp record, populated with the lines lines with boolean = false. Don't filter the temptable.
    in the onclose trigger of the form, flush the modified temporary records to the real table.

    fifth: In RTC (3 levels) your problem does not happen (i mean that if the user modifies the boolean field, the record does not disappear unless you explicitly refresh the page)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kash387kash387 Member Posts: 111
    I want to do it because its requirement.

    Let me be more clear....

    I have ImpTable, which will store the data when its get imported from .txt file. During import, it will do some validation and if there is/are error(s) then it will import data with boolean(Has Error) true. The error will be stored in another table named error tracking.

    Now, the form is having filter on OnOpen trigger: SETRANGE(Boolean,TRUE);

    Means, it will show only data that is havin error.

    Then there is a button named Recheck Error, which have codes that recheck the error, whether it is being resolved after importing the data, if it is, it will rectify the error and the boolean field will be cleared.

    So now, the thing is that when I am doing this, and CurrForm.UPDATE runs, it just removed the rectified data as the Boolean is set to FALSE.

    Thats where I am stuck.

    Thanks

    Kashyap
    Thanks,

    Kashyap
  • BeliasBelias Member Posts: 2,998
    use the temptable solution i've given before, if applicable
    otherwise, don't filter the boolean value and let the user do it if he wants.
    the behaviour of the form is perfectly correct
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kash387kash387 Member Posts: 111
    Thanks Belias, but i m thinking that OnOpen Trigger should be fired only when the form is opened. Once it is open and you are doing anything it should not affect the current filters.

    This is what I mean for OnOpen Trigger uptill now.

    Thanks

    Kashyap
    Thanks,

    Kashyap
  • BeliasBelias Member Posts: 2,998
    yes, onopen is fired only once, but the "rec" is the working variable of your form: if you set a filter on it at the beginning, it lasts until you remove it!
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • David_SingletonDavid_Singleton Member Posts: 5,479
    kash387 wrote:
    I want to do it because its requirement.

    :shock: Are you saying that in the requirement the customer told you the code you must use, i.e. told you to put set range and currform.update like this?

    This is very strange. Normally my customers give be a business requirement and I will be the one that tells them how it will be done in Navision, and I decide what code will be used. If you have a client like this, then I guess they have their own development team. In which case its best if they ask on the forums instead of you.
    David Singleton
  • BeliasBelias Member Posts: 2,998
    kash387 wrote:
    I want to do it because its requirement.

    :shock: Are you saying that in the requirement the customer told you the code you must use, i.e. told you to put set range and currform.update like this?

    This is very strange. Normally my customers give be a business requirement and I will be the one that tells them how it will be done in Navision, and I decide what code will be used. If you have a client like this, then I guess they have their own development team. In which case its best if they ask on the forums instead of you.
    It was also my thought...but i think it's a language issue this time...after saying that he has explained what was the business requirement :)
    kash387 wrote:
    Let me be more clear....

    I have ImpTable, which will store the data when its get imported from .txt file. During import, it will do some validation and if there is/are error(s) then it will import data with boolean(Has Error) true. The error will be stored in another table named error tracking.
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kash387kash387 Member Posts: 111
    kash387 wrote:
    I want to do it because its requirement.

    :shock: Are you saying that in the requirement the customer told you the code you must use, i.e. told you to put set range and currform.update like this?

    This is very strange. Normally my customers give be a business requirement and I will be the one that tells them how it will be done in Navision, and I decide what code will be used. If you have a client like this, then I guess they have their own development team. In which case its best if they ask on the forums instead of you.

    Hello David Sir,

    I really respect you and your answer is absolutely right. It might be mistake from my side to explain you.

    Sir, clients (mostly) never tell you to write code this way and if any of my client is telling me the thing I wont do what he is saying. Because its my duty and my job to write codes and design the formats not client's.

    Second thing, I am given the scenario and the explanation what they want. Now, I am not too powerful in NAV yet, so I need advice from you experts. And the question was not just because of the requirement, its also for increasing my knowledge regarding the matter.

    Thanks

    Kashyap
    Thanks,

    Kashyap
  • kinekine Member Posts: 12,562
    Then there is a button named Recheck Error, which have codes that recheck the error, whether it is being resolved after importing the data, if it is, it will rectify the error and the boolean field will be cleared.

    So now, the thing is that when I am doing this, and CurrForm.UPDATE runs, it just removed the rectified data as the Boolean is set to FALSE.

    And when you are expecting that the entry will be hidden from the list of records with error? I recommend to use new field "Error solved" and set this flag if the error was rechecked successfully. Than you know that the error is removed and the Error boolean will be still same, thus record will be still visible.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • kash387kash387 Member Posts: 111
    Thanks Kine for your solution,

    I have removed the filter on that field, instead i put filter for another one that is more important and i also explained to my superiors also. what I actually wanted to know was the characteristics of OnOpenForm Trigger....Belias has explained me that.

    So thanks a lot experts,

    Belias, Kine and David Sir,

    Thanks again

    Kashyap
    Thanks,

    Kashyap
Sign In or Register to comment.