close method call prevention when more than one times a same form is opened

Hi all,

   I am facing issue on ax 2009, At first I have written a piece of code to send mail to the contact person in the contact person form close method when some changes made, when I open two contact person form for same busrelation and when i make changes in one contact person form and while closing both the form one after the other two times the process is carried , instead I want only one time to process , and second time the process should not take place. Please suggest some answer if possible.





Thanks in advance,


  • Gopinath M
    form close method when some changes made, when I open two contact person form for same busrelation

    Shouldn't you be having you code after doing the update rather than form close?

    Why cannot you use the alert functionality? 

  • In reply to Kranthi:

    actually there is change for checkbox value to determine a main contact person, so since there possiblity of changing it many times, the code is written in close method for the sake of final confirmation (where the value in the table is compared with new and old value which includes a map) this is happening two times . when closing two forms, i wanted this to happen once, Please can you suggest any ways to stop this.
  • In reply to Gopinath M:

    The approach is not correct and it will create issues in a multi user environment.
    Use alerts (or) trigger your code after record update is committed.

  • In reply to Kranthi:

    But is there any way to stop from calling close method on the second time, or refresh the form and datasource complete before second time calling close method ? please suggest kranthi
  • In reply to Gopinath M:

    If you stop calling the close method, then the form will never be closed.
    You can try data source reread.
  • In reply to Kranthi:

    I wrote refresh code like element.task(2876); in the beginning of the close method so that before refreshing the second form will also get refreshed and so that process will not work. but this is not working, i need to refresh everything before that process hits, i need help in that please suggest an answer.
  • In reply to Gopinath M:

    Gopinath M
    i need to refresh everything before that

    What do you mean by refreshing everything?

  • In reply to Kranthi:

    Hi Kranthi,
    I meant refreshing the form before closing(Note: coding for entire process while closing the form is written before the super() of the close method) before this code execution i need to refresh that form and then continue to close so that data will be updated i hope.Can u suggest a solution please
  • In reply to Gopinath M:

    You mean refreshing the data shown in the form? If so ds.reread and ds.refresh should take take care of it.