UserID in the Employee Table

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 company.

As well when the status of the Employee is Inactive, then it should not allow me to enter into the company.

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

As per the suggestions , I have placed the coding in 1 codeunit in LogInstart trigger. the following code is as follows



recemployee.RESET;
recemployee.SETRANGE("Users IDD",USERID);
recemployee.setfilter(recemployee.Status,
'%1|%',recemployee.Status::Inactive,recemployee.Status::Terminated);
IF recemployee.FINDFIRST THEN
ERROR('Employee %1 does not exist',recemployee."Users IDD");

Even though after placing the code, it allow the user to enter into the company without exit.

Waiting for your valuable suggestions.
Jai

Comments

  • kapamaroukapamarou Member Posts: 1,152
    Have you debugged your code to see what values are used?
    Is the following a typo?
    njaiku wrote:
    recemployee.setfilter(recemployee.Status,
    '%1|%',recemployee.Status::Inactive,recemployee.Status::Terminated);
  • kinekine Member Posts: 12,562
    Error in CU1 will not prevent user to login into the company. You can use SENDKEYS to send keystrokes to close the database. There is no standard way how to do this from C/AL. But you can use the SQL trigger which is called each time the user logs in and this will prevent the user to login...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.