How can i link a user (login) to a specific employee record? Is there an existing function inside Servoy for this or do i need to program this myself.
An example would be much appreciated.
You can retrieve the username using security.getUserName(). This will return a string containing the username. If your employee record contains this username string, you can then create the link you’re looking for.
You will need the mustAuthenticate checkbox checked at the solution level of course, and at least one user setup.
What you do from here depends on how you want to use this link?
Can set user’s UUID to the the pk of the employee, then load the employee record by using security fx to fetch the logged in users UUID.
There really is no need to link a user to an employee. Instead, you should be linking your employee records to Servoy groups. (Just add a field with value list and use Security.getGroups() )
If you build your own login form (which you should), then you can use the Security.login function. In that function, you can pass in your own display name, id, and groups array. So for example if you have employee_id and employee_name in your employee table, along with employee_group which contains the Servoy group they belong to, this would work:
Security.login(employee_id, employee_name, [employee_group])
//employee_group must exist or login will fail
Of course if you allow multiple groups per user, then you could adjust that a bit.
This will also work with the Servoy audit log if you are using that. so the employee_id will get logged in the log table.