Wrong behavior OnModify?

JamboJambo Member Posts: 12
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

  • rthswrthsw Member Posts: 73
    Do you have more Information about your System?
  • krikikriki Member, Moderator Posts: 9,110
    On a form, when you leave the last keyfield, Navision saves the data (=INSERT).
    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.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • JamboJambo Member Posts: 12
    @Kriki
    Then if you change something, when you leave the record, Navision saves the data again (=MODIFY);
    I am changing nothing. I just scroll up or down after inserting some values, and I am getting the message "I am in OnModify trigger".

    @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.
  • krikikriki Member, Moderator Posts: 9,110
    Jambo wrote:
    @Kriki
    Then if you change something, when you leave the record, Navision saves the data again (=MODIFY);
    I am changing nothing. I just scroll up or down after inserting some values, and I am getting the message "I am in OnModify trigger".
    -after inserting some values, you just scroll up or down sounds like that you are putting some value in some fields. When you leave the record, Navision saves it to the DB (=MODIFY). Or do I interpret your phrase wrongly? In this case, you need to write EXACTLY what you do, otherwise we can only guess.
    -Are you sure you don't have any code in other places with the same message? You can find this by using the debugger.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • JamboJambo Member Posts: 12
    @Kriki

    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?
  • krikikriki Member, Moderator Posts: 9,110
    Jambo wrote:
    Now I click into Desc field. Provide it with some values and press enter.
    I suppose you want the value you just entered in the description-field to be saved to your DB?
    Navision needs to do a MODIFY (you just created the record with the INSERT before) to save the description-field into your record.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • JamboJambo Member Posts: 12
    Kriki,

    many thanks for clarification. I am now able to anticipate what will happen and why.
  • krikikriki Member, Moderator Posts: 9,110
    Jambo wrote:
    Kriki,

    many thanks for clarification. I am now able to anticipate what will happen and why.
    You're welcome. I am happy I could help you.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.