Hi,
Since I couldnt find the answer I was looking for on the other posts with similar title I thought of creating a new one.
I have a record which I do some calculations with it in a codeunit. After my calculations the record has, say, COUNT = 3. If I pass this record to a form in the following way everything is fine:
MyForm.SETRECORD(MyRec);
MyForm.RUNMODAL();
In the form now the MyRec has COUNT = 1.
However if I do:
FORM.RUNMODAL(FORM::MyForm, MyRec);
Then the form displays all 3 records.
Note that the MyRec variable is a parameter to a function in the codeunit. In this function the calculations are being done and the form is being run. The VAR check box is checked in the MyRec parameter and the codeunit is SingleInstance = NO.
Can someone please explain me the difference and how can I use the first way and make it work?
Thanks in advance.
Answers
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I dont have any filters set on this record (MyRec). I even do a RESET just before I pass it in the form (after the RESET the COUNT is 3). :-k
At least that is what I think you are saying..
What does the code inside your SETRECORD function do?
It should look something like...
SETRECORD(inputRecord)
globalFormRecord := inputRecord;
And you shouldn't have to pass by reference, by value should be fine...
No one loves you like the one who created you...
Yes you understand corectly what I want to do.
The only difference is that the SETRECORD is not my function. Is the standard C/AL function to pass a record in a form. I dont know what it does, its not visible in the form.
Thanks for the reply
I.E. on the form create a function called and do the assignment within the function
Now you have a way to set the current record you wish to calculate before you run the form.
Since you are doing a runmodal, you can even retrieve response or return variables from the form before it is destroyed by creating a get function as well. This is usually how I handle passing variables between forms.
No one loves you like the one who created you...
Here is the function: ](*,)
2) SETRECORD is passing filters from your variable to the form
3) If you reset all fitlers, you will see all in your form...
4) If you use SETRECFILTER, you will see just the actual record in the form
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Kine, Thanks for your explaination. Unfortunately, I had all those in mind and still I must be doing something wrong. Here is again my code:
1st way:
2nd Way
The 2nd way displays all 3 records in the form unlike the 1st way.
Thanks[/b]
in your code you have:
and than you wrote, that you are using
Why? The first RUNMODAL is enough to run the form. The second command run the same form, but on MyRec which has no filters (you did reset before). It is not affected by function SetMyRec called before...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Kine,
The bit you didnt understand is that I have 2 DIFFERENT WAYS of running the form. Please see previous post for 1st way and 2nd way. The 1st DOESNT work and the 2nd WORKS! I dont use both ways at the same time obviously.
Thanks
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I mentioned before that there are no filters in MyRec when I pass it in as a parameter. I do check it with the MyRec.HASFILTER() function before I pass it to the form and also from inside the form C/AL code I check it again. On top of that, just to make sure, I do a MyRec.RESET just before I pass it in the form as you can see in previous posts above. ](*,)
http://www.mibuso.com/forum/viewtopic.php?t=20440&highlight=
Thanks