Code in trigger on form runs more than once

ReinoudReinoud Member Posts: 58
I noticed that the code in F151 onaftergetrecord runs more than once. That is strange because it is only 1 customer which is retrived as a record. I saw that because i added some other calculations which should only run once. Then I checked some other forms f.i. customer card. This piece of code in the onaftergetrecord runs about 5 times. Why is that, where is that coming from?
Reinoud

Comments

  • ufukufuk Member Posts: 514
    If you run the form modally then it loops twice. If you directly run it only runs one time. But it does not run 5 times in my database. I am not sure about the reason but I think it is something related with RunFormLinkType property because when the form is updated then OnAfterGetRecord trigger runs.

    On the other hand you can use a variable to make sure your code runs only once (if you are asking about that :D ).
    Ufuk Asci
    Pargesoft
  • ReinoudReinoud Member Posts: 58
    I solved it by setting the variables back to zero before running the code. But that still is a waste of computer time. I did what you said with a global boolean variable but tht is not working because the value remains true when you walk through the customers on the statistic form (Because defined as global it will not reset).
    Anyway it remains strange to me that this runs twice. (Did you check the customer card and this trigger? I did not change anything just looked at the times that it passes the header, it realy is 5 times)
    Reinoud
  • ufukufuk Member Posts: 514
    You can use an Integer type variable. Reset it when the form opens and increase in each getrecord and do while it is in your range.

    Customer Card's UpdateOnActivate property value is Yes. So triggers like OnFindRecord, OnAfterGetRecord, OnAfterGetCurrRecord runs twice. But it only runs twice in the Cronus database.
    Ufuk Asci
    Pargesoft
Sign In or Register to comment.