i have got an problem in a form, i want the onaftergetrecord trigger to run only once on opening the form, but later when you scroll through your lines it should run every time.
Maybe you can use a global variable wich you set when your code
has run once. The code will only run when it's false (Boolean is default False), after the code has run you set the variable on true, so it won't run again.
WHAT DO YOU WANT TO DO??? Without details I cannot help you... OnAfterGetRecord is called when row is read from DB. On open form is for each row in cache, after scrolling for each new record etc.... why you need to call it only once? Why do you need to call it after that?????? :?: :?: :?: Still too much question without answers... :?
It´s hard to describe, but i´ll try. I have got an array which i have to fill with the first record on the table when the form is opened. Later, when the user scrolls in the record, i have to modify the array again and again.
But i have nearly solved the problem...
the array is something as record history? What do you mean with "the user scrolls in the record"? it means, that user select this record again? What you change in array? Why not use OnAfterGetCurrentRecord?
I am still asking, I know, but my brain is working and there are many solutions for many things... 8)
In fact it doesn´t matter what i want to do, because that what i want to do with the array works perfectliy, what i need is an idea how i can run the code in the on aftergetrecord trigger once, when i open the form. Because there are displayed 4 records in the the list, so the on aftergetrecord is executed 4 times, so the pointer is on the first record of the list and the according data in the array is for the last record in the list. Because i fill the array in the on aftergetrecord.
The programm is too complex for describing it here, sorry.
I will join the rest of the guys who answered you, Warfox. Simply use a global variable on the form e.g. a boolean. Set it to true the first time you retrieve the record and set up a if-condition for the rest of your trigger code based on that boolean. The value of the variable lives as long as the form lives.
thx oleschjoeth, but can you tell me on which trigger i have to set the boolean back. No kine i have to need the first record, but with a find ('-') it doesn´t work *g* i have nearly solved the problem by using an integer counter but it doesn´t work perfectly.
Still, i have no information to be able help you. If you can't tell us what do you want to do, I am not able to help you. I can only guess the answer for your question...
Warfox, why would you want to set it back? As Kine says, if you don't want to tell us what you are trying to achieve it's very difficult to help you. Me might suggest a solution that won't work for you because we see your problem out of context due to your lack of information
hy, good news, i´ve solved it.
It was a little bit difficult, but here is the code:
Form - OnopenForm
openform := TRUE;
counter2 := 0;
records := 4; //The records that can be shown in the form at one time
Form - OnAfterGetRecord()
CALCFIELDS(Splittcount);
CALCFIELDS("Finished Positions");
CALCFIELDS("Position Finished");
counter2 := counter2 + 1;
IF (counter2 = 1) OR (openform = FALSE) THEN BEGIN
FOR counter := 1 TO 4 DO BEGIN
Split.RESET;
Split.SETRANGE("Picknr.","Picknr.");
Split.SETRANGE("Zeilennr.","Zeilennr.");
Split.SETRANGE("Fachnr.", STRSUBSTNO('%1',counter));
IF Split.FIND('-') THEN BEGIN
Amount[counter][1] := Split.Menge;
IF Split.Menge = 0 THEN
Amount[counter][1] := Split."Bestellte Menge";
Amount[counter][2] := Split."Bestellte Menge";
Textfield[counter][1] := STRSUBSTNO('%1',Amount[counter][1]);
Textfield[counter][2] := STRSUBSTNO('Filiale:\%1',Split.Filliale);
END ELSE BEGIN
Amount[counter][1] := 0;
Amount[counter][2] := 0;
Textfield[counter][1] := STRSUBSTNO('%1',Amount[counter][1]);
Textfield[counter][2] := '';
END;
END;
END;
IF counter2 >= records THEN
openform := FALSE;
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
has run once. The code will only run when it's false (Boolean is default False), after the code has run you set the variable on true, so it won't run again.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
But i have nearly solved the problem...
I am still asking, I know, but my brain is working and there are many solutions for many things... 8)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Sometimes a man cannot see a solution because he's looking to close.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
The programm is too complex for describing it here, sorry.
Regards,
Ole
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
sorry
:?:
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Ole
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
It was a little bit difficult, but here is the code:
Form - OnopenForm
openform := TRUE;
counter2 := 0;
records := 4; //The records that can be shown in the form at one time
Form - OnAfterGetRecord()
CALCFIELDS(Splittcount);
CALCFIELDS("Finished Positions");
CALCFIELDS("Position Finished");
counter2 := counter2 + 1;
IF (counter2 = 1) OR (openform = FALSE) THEN BEGIN
FOR counter := 1 TO 4 DO BEGIN
Split.RESET;
Split.SETRANGE("Picknr.","Picknr.");
Split.SETRANGE("Zeilennr.","Zeilennr.");
Split.SETRANGE("Fachnr.", STRSUBSTNO('%1',counter));
IF Split.FIND('-') THEN BEGIN
Amount[counter][1] := Split.Menge;
IF Split.Menge = 0 THEN
Amount[counter][1] := Split."Bestellte Menge";
Amount[counter][2] := Split."Bestellte Menge";
Textfield[counter][1] := STRSUBSTNO('%1',Amount[counter][1]);
Textfield[counter][2] := STRSUBSTNO('Filiale:\%1',Split.Filliale);
END ELSE BEGIN
Amount[counter][1] := 0;
Amount[counter][2] := 0;
Textfield[counter][1] := STRSUBSTNO('%1',Amount[counter][1]);
Textfield[counter][2] := '';
END;
END;
END;
IF counter2 >= records THEN
openform := FALSE;