Confirming Application Close

headley27headley27 Member Posts: 188
Is there any way to do this in 5.0?

I was able to do this in 3.7 by running the following code prior to closing Form 330 (Main Menu):

Form - OnQueryCloseForm() : Boolean
IF NOT CONFIRM('Are you sure you want to close your connection to the Navision Database?',FALSE)THEN
ERROR('');

Although closing Form 330 didn't really 'close the database', the users didn't know any different, and they could 'opt out' of closing Navision prematurely.

In 5.0, I tried the CompanyClose() and LogInEnd() triggers in CodeUnit 1 (ApplicationManagement) with no success.

Does anyone have any idea how I might achieve this?

It is far too easy to accidentally close the application.

Thanks in advance,

headley27

Comments

  • Revolution1210Revolution1210 Member Posts: 161
    Tell your users not to press the red X unless they want to close the application :D

    Seriously, I don't think there is much you can do, certainly in terms of injecting code into codeunit 1.

    NAV is no different to any other Windows app in terms of users accidently closing down... ..what's the worse that can happen? they have to restart the client.
    Ian

    www.NextEqualZero.com
    A technical eye on Dynamics NAV
  • headley27headley27 Member Posts: 188
    This works:

    I'll use CodeUnit 1 (ApplicationManagement) to launch a Custom Form that is not visible.

    This form will contain the code that presents the choice to the user, allowing the user to stop the application from closing:

    Form - OnQueryCloseForm() : Boolean
    IF NOT CONFIRM('Are you sure you want to close your connection to the Navision Database?',FALSE)THEN
    ERROR('');
  • Revolution1210Revolution1210 Member Posts: 161
    What about your super/power users who actualy know that they want to close NAV - I think they will get a bit annoyed with the message... ..I know I would, but if it works for you then cool :D

    ...but I'm pretty sure your solution will cause navsion to GPF if you call it from CompanyClose() or LogInEnd()... ..i could be wrong :D
    Ian

    www.NextEqualZero.com
    A technical eye on Dynamics NAV
  • headley27headley27 Member Posts: 188
    Our remote users access Navision via Remote Desktop Connection.

    The Terminal Server that they access is locked down to the point that Navision opens by default without a desktop, taskbar, etc. and only applications launched by Navision can be used.

    When the user closes Navision it closes the session on the Terminal Server. Logging back in takes a little time so the code I used in 3.7 made everyone happy. This included local users who didn't like that Navision could be accidentally shut down with a missed mouse click and as a result, would force them to relaunch Navision and all of their open forms, etc.

    The CompanyClose() and LogInEnd() are only called if the User clicks 'Yes' to the confirmation message allowing 'Navision to close'. If the User clicks 'No' the hidden form doesn't close, spawns a silent error, and effectively stops the application from closing.
Sign In or Register to comment.