Dialog window sticks when error comes.

rushabh149
rushabh149 Member Posts: 15
Hi,

I am running the codeunit from a form. In the codeunit I am using dialog window which updates on each record and finally closes.

The problem that happens is that whenever some error occurs(validation, data absence) during the execution of the codeunit error message comes, still the dialog remain open. It looks odd, and I want that whenever some error occurs, the dialog window should close without user intervention.

Thanks in advance

Comments

  • kriki
    kriki Member, Moderator Posts: 9,121
    I think it is because you have the codeunit defined as a variable in the form.
    If your codeunit has an error, the transaction is undone, but all the variables in the codeunit remain active until you do a CLEAR.

    If you run the codeunit with CODEUNIT.RUN, this should not happen because the instance of the codeunit is cleared.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ara3n
    ara3n Member Posts: 9,258
    You can also create the variable as local variable in your function and it will clear automatically.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • rajpatelbca
    rajpatelbca Member Posts: 178
    hi rushabh149,

    Its so simple.. :)

    when you call codeunit from the form dont create a variable of a codeunit.
    just write this way.

    use following syntax :
    CODEUNIT.RUN(CODEUNIT::"dialog test")

    when error comes dialog box automatically closed.

    Regards,
    Experience Makes Man Perfect....
    Rajesh Patel
  • MatthiasKönig
    MatthiasKönig Member Posts: 14
    Hi,

    sorry that i post in this "old" thread but i've the same problem.

    the answer of rajpatelbca is correct but i've two problems with that:
    1) why occurs this error (!)?
    2) how can i use functions of a codeunit in this case?


    kind regards,
    Matthias


    EDIT:
    aahhh the scope is the problem......do not use globals :D

    SOLVED :D
  • kine
    kine Member Posts: 12,562
    Hi,

    sorry that i post in this "old" thread but i've the same problem.

    the answer of rajpatelbca is correct but i've two problems with that:
    1) why occurs this error (!)?
    2) how can i use functions of a codeunit in this case?


    kind regards,
    Matthias


    EDIT:
    aahhh the scope is the problem......do not use globals :D

    SOLVED :D

    Yes, the scope is the problem here, because if the variable is still valid, the dialog will not close. If it is in something what is not valid anymore after error, the dialog is disposed automatically...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • matttrax
    matttrax Member Posts: 2,309
    sorry that i post in this "old" thread

    Points in my book for actually searching for a solution before posting your problem. =D>
  • DenSter
    DenSter Member Posts: 8,307
    matttrax wrote:
    Points in my book for actually searching for a solution before posting your problem. =D>
    Yeah same here, I always love it when people add something to old posts :mrgreen:
  • Belias
    Belias Member Posts: 2,998
    oh!this is the reason for this to happen!
    i've had the same problem a pair of years ago, but i left it unsolved because the problematic object wasn't developed by me...good to know, thanks for pointing this out :thumbsup:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog