Best way to assign an user to a employee when signing in
Application Type

Hello ! 

So i have the table User and the table Employee with differents informations and i would like to know what is the best method to create an Employee automatically when a User signs in and link them together. 

I want to do that because im building an Employee management application and i need to assign differents roles and permissions.

I have tables User, Company, Project and Employee and roles Company, Employee, EmployeeAgent and Manager. 

Hello Jeremy, 
I noticed that you are new to OutSystems. First of all, welcome to the community. 
Did you already notice that there is a step-by-step guide path for a similar employee management application? Check it out: 

Best regards, 


Hello thanks for your answer, unfortunatly this guide doesn't cover the roles

Hello again Jeremy, 
This one does, and again, it is a how-to guide path, step by step:

First you have some videos explaining the official documentation and how role security is managed in OS and after that you have an how-to exercise/example :) 

Best regards and luck, 


HI @jeremy laisne 

As I understood you want to assign User to employee who has created new employee, If this is the case then add an attribute in Employee table named CreatedBy of user identifier and assign value GetUserId() it'll return logged in user id,

If this is not the case then please describe your requirement in more details,

I hope it'll  help you,



Hello, no i want the user to be the employee, i have a foreign UserId in my Employee table to link them together but i have to do it manually, i want to find a way to do it automatically. 

Because my problem is  that i have to register a User and an Employee who are the same person, and the admin link them together manually with UserId. 

So i want to create the employee at the same time i create the User.

I don't know if its clear

Hi @jeremy laisne 

Okay, it's fine there is two way whenever you create a user problematically or from the code then after create user you'll receive created user id,  So after user created you can put your action to create new employee with the same details and user id,

Then User_Roles entity persist roles of user, you can do some code upon that as well, to assign multiple roles to a user,

You can also do it on runtime Grant<RoleName>(userid) action.

I hope it'll help you,



Hi Jeremy,

You could grant the role to a user when they login inside the DoLogin() action which you could find from the screen below.
For sure, you need to created the Employee Role already in your application so you will have the GrantEmployeeRole action.

Hope this help.

Hello @jeremy laisne,

Have you resolved your query ? if not then, please refer below screenshot It will definitely help you. 


Shriyash Dixit

Hey there!

What if you try doing it like the grant role in the guided path demo?

I have a list of employees (not necessarily users yet). I want to make one of them a manager (a role I have). I can grant a Manager Role to an existing user in OutSystems, but what if that employee is not even a registered user? How do I do both actions at the same time?

I have some employees (not all have users associated) and when the manager wants to grant a role to one of those employees in the list, it also has to create a new user.

I was doing the demo of the guided path (https://learn.outsystems.com/training/journeys/web-developer-662/demo-how-to-grant-a-role-to-a-user-in-logic/o11/3679)

but the file is not even working. I am also imagining that it was done with an employee that was created as a user and not the other way around.

The video at https://www.youtube.com/watch?v=cUqt0tD_Pi8 covers it if I am creating a new user through Service Studio and then granting a role, but is there a way to do it as I considered it?

Thank you in advance!

(I had an app where we had a client list for a hotel staff to check... then later we decided some would be good to have some of them registered if they wanted to access a private area of their bookings, but we had 2 tables - users and clients not connected. If I created a user then it was ok but if I had a client created before, he wouldn't have a user assigned. #)

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.