How to prevent a company from opening

GaryDGaryD Member Posts: 66
Hello All,
We're using NAV 5.1 with SQL Server 2005. We have a production database and a test/development database. We occasionally want a user to be able to access the test db for testing purposes. We've set a flag "OKInTestDB" in the Salesperson/Purchaser table for this access. And in the CompanyOpen function of codeunit 1 we check for this flag and if the user is not flagged we do a Sendkeys F4 which kicks them out of NAV altogether. What I'd like to do is to only kick them out of the company so that NAV is still open. Better yet, I'd like to display a message to the user telling them that they are not allowed in this company before kicking them out. I've seen examples on the internet about doing sendkeys with F,M and C to close out the company, and that works correctly from a form button. But when I try to use it from the CompanyOpen procedure, the company still opens. It also doesn't work if I do it in a form Open trigger where the form is called from the CompanyOpen procedure. Any ideas?

Thanks!

Comments

  • ara3nara3n Member Posts: 9,256
    I suggest to use Permission.

    When you assign roles, you can make the roles company specific. Thus a user will not be able to go to a test company.

    If a user needs to go to that company then assign the roles for that company.


    Just on open company add the message, 'You are in test company'
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • GaryDGaryD Member Posts: 66
    Thanks Rashed, I'll look into that but I believe manipulating Roles is not going to be what we want. What we have works. It's just a bit rude to shut down Nav without letting the user know why.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    GaryD wrote:
    Thanks Rashed, I'll look into that but I believe manipulating Roles is not going to be what we want. What we have works. It's just a bit rude to shut down Nav without letting the user know why.

    Gary,

    Rashed's response really is the best way to solve this. Anything else you do will just go on for ever.
    David Singleton
Sign In or Register to comment.