Codeunit 1 / LoginEnd (solved!)

Howdy, We are running NF2.60. I have added some code to the LoginEnd function in codeunit 1 to reset a session flag which I have created in the UserSetup table. Everything works fine. But then… A user complains that this flag gets cleared in the middle of his session. He claims he did not change company, log out etc. Now my question: Are there any other events besides logging out and changing company that could trigger the LoginEnd function? Thanks a lot for your help.

Hi Heinz, I am pretty sure that the LoginEnd and Login Start get called whenever the Main Menu is opened or closed. So therefore if by mistake he escapes out of the main menu then it calls the LoginEnd even though you did not change company or logged out … Cristi

P.S. I guess this is one of the few cases where the user IS actually right [:D]

You could prompt the user durring the “OnQueryCloseForm” event and raise an error to cancel the close if the user is closing the Main Menu on accident.

Thanks for your answers! Cristi, I just tried this - you are right, LoginEnd gets called upon simply closing the main menu. Unfortunately, this doesn’t explain what happened. To give you some more details: We added some code to prevent accidental modification of certain important tables, e.g. customers, suppliers, G/L etc. If a user wants to modify such a table, he has to press a button on the main menu, setting a “session flag”. A status line indicates whether modifications are currently allowed or not. The corresponding flag is stored in the UserSetup table, checked upon modifications and cleared upon logout. When I close the main menu, the flag gets cleared and upon re-opening the main menu, the status bar (which checks the flag) correctly indicates that modifications are disabled. But our user claimed that the status bar was set to “enabled” all the time, and still he could not modify one of the protected tables. The flag was actually cleared, but without the status bar noticing this. So LoginEnd was obviously called (there is no other way for the flag to get cleared besides manual intervention), but without closing and re-opening the main menu. Confusing…

Why not set EDITABLE to FALSE in the forms when opening these important tables and create a function in the form to make it editable. You can also set a shortcut key to the function. F8 isn’t used in standard Navision. /Lars

Lars, this is of course a good alternative, but: 1) Putting the code into the table is more “central” than putting it into each and every form that shows this table 2) It was our intention to switch the session into a “modification session”, so switching should take place in a central location, not individually on each form 3) Most important: Our solution has been working for quite a few months by now, and our users are accustomed to it [;)] The strange effect described above has been reported only recently, by a single user.

Hi heinz

quote:


Originally posted by xorph
… The strange effect described above has been reported only recently, by a single user. …


Perhaps it would be helpful to remove the user [:D]! bye André

quote:


Originally posted by Andre DDB
Perhaps it would be helpful to remove the user [:D]!


I don’t think he would appreciate that… [B)]

Hi Heinz, First I would like to say that there have been many times where I felt that Andre’s solution of removing the user would be the best also [:D] However since we are not living in a perfect world [;)] … First, if I am understanding properly, you are using UserSetup table to store the flag. That may be a problem since what happens if I want to open up more than one Navision? Or if someone else logs on under his user? I would suggest using a different table where the key field would be the Session No. … The session ID is always unique … So you would insert a record there when LoginStart and remove the record when LoginEnd. Then rinse and repeat [;)] Hope this helps … Cristi

Another suggestion: To avoid using up another table you could just create a SingleInstance codeunit and use a global to store the value (only if you are using Attain) … Then you would call a function in the codeunit that returns the value of the global for testing … The advantage of the table method though would be that at any point in time you could see what each user is set to … Cristi

Please Use Code Unit of Id 1 - ApplicationManagement, Its defenitely calls While any action occurs for Login and Logout Thanks

quote:


Originally posted by cnicola
First I would like to say that there have been many times where I felt that Andre’s solution of removing the user would be the best also [:D]


I presume this thought has come to each of us admins from time to time [:p]

quote:


First, if I am understanding properly, you are using UserSetup table to store the flag. That may be a problem since what happens if I want to open up more than one Navision? Or if someone else logs on under his user?


Good point. We have a lot of users who work in several companies simultaneously. The user I mentioned just confessed that he actually did open Navision a second time during his “modification session” [:D] Problem solved [^] Thanks a lot to all of you for your input! I knew this forum would once again rescue me! [8D][8D][8D]