OnInsertRecord() trigger in Form executing twice

ckndr47ckndr47 Member Posts: 100
I know its not a good practise to have code in the OnInsertRecord trigger of the form; but due to certain business logic i have no other choice.

Problem:

So here is my problem. I have main form, and a sub form. The subform is linked through SubFormId, SubFormLink property.

In the OnInsertRecord trigger of my subform i have some code; now what happens when i try to insert a new record i could see my trigger executing twice which results in abnormal behavior.

I have done a work around for that by playing with the boolean flags; which is actually stopping the trigger to execute 2nd time.

But what i am curious abt is why this trigger is getting fired twice, that has never happened before, its been years.

Somebody told me that its a problem with Navision Executable but still there has to be a workaround; becuz its totally abnormal and strange.

Need your expert opinion about that.

Thanks and Regards,

Comments

  • SavatageSavatage Member Posts: 7,142
    is there code on the table & form OnInsert?
  • ckndr47ckndr47 Member Posts: 100
    Yeah there is some code in the OnInsert() trigger of table and OnInsertRecord() trigger of form.

    But the triggers are executing twice; there is no other code in the form or table apart from that.
  • Tazzy1972Tazzy1972 Member Posts: 18
    There are 2 triggers than 1 in the table and 1 in the form. So the triggers will be run twice.
  • ckndr47ckndr47 Member Posts: 100
    @Tazzy1972
    hahahahah... good reply...
    thanks man i didnt know abt that :) lol
    I think u didnt read the post correctly

    What i am saying my triggers are executing twice; so twice in form, twice in table. Cuz its a problem in Navision executable i know that, just wanted to confirm with you guys if u ever come across with a situation like that.
  • kinekine Member Posts: 12,562
    Sometimes this can be because some CUrrForm.UPDATE or SAVERECORD in the code during saving the record. Than it start the insertion process one again... check that.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • ckndr47ckndr47 Member Posts: 100
    There is no such code like CurrForm.UPDATE or SAVERECORD
    Its really very strange
Sign In or Register to comment.