Retrieving the current user that is logged in

Hi guys i would like to retrieve the current user that is logged in as the main page. Example after the user login i would like to have a page "Welcome User1" The screenshot below shows the the variables that i have fetched from the database but i am not sure if this is the correct way to do it. Please advice me thanks

Hi Koalified,

Follow below steps.

1. Outsystems has built in function to get current logged in user id ( BuiltFunctions -> Roles -> GetUserId() )

2. Use GetUser function in Preparation to get user details and use them in web screen.


Hope this helps.

Sravan

Sravan Vanteru wrote:

Hi Koalified,

Follow below steps.

1. Outsystems has built in function to get current logged in user id ( BuiltFunctions -> Roles -> GetUserId() )

2. Use GetUser function in Preparation to get user details and use them in web screen.


Hope this helps.

Sravan


Hi i would like to ask is it possible to use "Username" as a primary key to another database ?

Hello Koalified.

1. It is better to use an aggregate filtered by the UserId against GetUserId(), than to use GetUser function, because the former will be optimized.

2. If it is an external database, in it you can use whatever you like and it is allowed. But you should have in mind that the attribute UserName in entity User is not "unique", so you can have problems if you don't pay attention to this detail. 

Why don't you use the user id? There is any reason?

Cheers.

P.S. You can't change the User entity in any way, as it is a System entity.

But you can extend it creating an extension entity, that is a new entity where the Identifier data type will be "User Identifier" (PK and FK at the same time) that will create a 1:1 relationship between them.

Eduardo Jauch wrote:

P.S. You can't change the User entity in any way, as it is a System entity.

But you can extend it creating an extension entity, that is a new entity where the Identifier data type will be "User Identifier" (PK and FK at the same time) that will create a 1:1 relationship between them.

Hi how i did was this

So i would like to "link" sheet1 to user in the system... So how do i "link" them?

I think you already did through the UserId FK on the Sheet1...
It is not a User Identifier data type?

Cheers.

Hi Koalified,

Be aware that you are querying Server Entities, not Local ones, which means that you are making a call to the Server, which may slow things down. I'd advise you to cache the currently logged in user name in case you need it more often.

Eduardo Jauch wrote:

I think you already did through the UserId FK on the Sheet1...
It is not a User Identifier data type?

Cheers.


it is unique but not used to link both data together...

Kilian Hekhuis wrote:

Hi Koalified,

Be aware that you are querying Server Entities, not Local ones, which means that you are making a call to the Server, which may slow things down. I'd advise you to cache the currently logged in user name in case you need it more often.


Hi what do you mean by cache? Is there examples?

With "cache" I mean store it locally, in a Local Entity.