Hi,
1) Create a table X with some fields.
Add this code to OnInsert trigger:
message('I am in OnInsert trigger')
Add this code to OnDelete trigger:
message('I am in OnDelete trigger')
Add this code to OnModify trigger:
message('I am in OnModify trigger')
2) Create a form Y from table X.
So, let's examin the behavior when one want to insert, modify or delete a
record. If you run the table the behavior is as you have expected. But if
you run the form the behavior is in some way different:
After you have inserted a record with F3, OnInsert trigger fires, but after
that if you want to scroll up or down in the form the OnModify trigger fires
also.
Why?
Answers
Then if you change something, when you leave the record, Navision saves the data again (=MODIFY);
To change the behaviour of the INSERT, put Form-property OnDelayedInsert to Yes.
This will ONLY save the record when you leave it.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
@rthsw
I am using Navision 3.70 with Cronus database. I have tested this behavior on card form and list form. Both with same result.
-Are you sure you don't have any code in other places with the same message? You can find this by using the debugger.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Ok. Let's go step to step.
First I press F3 to insert new record (no matter list or card form). I have two fields (No., Desc). I provide No. with some value and press enter. At this moment OnInsert trigger fires (as expected). Now I click into Desc field. Provide it with some values and press enter. Here comes the special moment: I want to see the other records, so I press the arrow keys or page up/down. At this moment OnModify trigger fires.
Just to say it again, I do not change or insert other values. And I have only the above mentioned code lines written in the table. Form C/AL code is empty.
My question is why OnModify trigger fires on this moment?
Navision needs to do a MODIFY (you just created the record with the INSERT before) to save the description-field into your record.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
many thanks for clarification. I am now able to anticipate what will happen and why.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!