Employee card with UserId

njaikunjaiku Member Posts: 116
Hi,

In the Employee table i have created the field UserID and linked with UserSetup table. In Employee form i included the field Userid where for each employee one userid is assigned. If userid is not mapped in the employee card then it should not allow me to enter into the database.

This needs to work for both in Windows login as well as in Database Login.

Looking forward for your valuable suggestions.
Jai

Comments

  • ShedmanShedman Member Posts: 194
    Build the check in codeunit 1, trigger LogInStart. Just throw an error if the requirements are not met and you will not be able to log in to the database.
  • njaikunjaiku Member Posts: 116
    Hi,

    Thanks for your valuable suggestion. I placed the coding in LoginStart. The code is as follows:
    recemployee.RESET;
    recemployee.SETRANGE(Status,recemployee.Status::Active);
    recemployee.SETRANGE("Termination Date",0D);
    recemployee.SETRANGE("Users IDD",USERID);
    IF NOT recemployee.FINDFIRST THEN
      ERROR('Employee does not exist'); 
    

    Placing this code in Loginstart doesn't work. It shows the error message but it allows me to enter into the company even the employee doesn't exist. Where should i have to place this coding??????

    Looking forward for your valuale suggestions.
    Jai
  • njaikunjaiku Member Posts: 116
    Hi,

    Can anyone help me out to find the solution?????
    Jai
  • JPHSCJPHSC Member Posts: 67
    close the application if you cannot find the employee ( try sendkey's and ALT + F4, there is enough to find on the forum about the sendkeys)
  • ShedmanShedman Member Posts: 194
    Maybe calling CompanyClose after you throw the error does the trick?
  • njaikunjaiku Member Posts: 116
    Hi,

    Even if i place the function company close after the code . It's not working.... Is there any solution its very urgent can anyone help me out?????
    Jai
  • ShedmanShedman Member Posts: 194
    If you use LoginEnd then your login should stop. Try calling that afterward.
  • KYDutchieKYDutchie Member Posts: 345
    Hi,

    If you are on SQL, you can use the stored procedure "sp_$ndo$loginproc" to do this check for you.
    If you raise an application error when the user does not meet certain requirements, the user will not be allowed to login.

    We've written an application that locks out all "regular" users except accounting during year end.
    We also use it for locking out users while performing maintenance.

    Regards,

    Willy
    Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.
Sign In or Register to comment.