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 i would like to ask is it possible to use "Username" as a primary key to another database ?
"Hi " + GetUser(GetUserId()).User.Name+ " ,Welcome to " + GetAppName() + "."
You can try with the above expression. You will get a result like below. (Ignore the icon, of course)
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:
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?
it is unique but not used to link both data together...
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.
Kilian Hekhuis wrote:
Hi what do you mean by cache? Is there examples?
With "cache" I mean store it locally, in a Local Entity.
thanks for sharing
i am looking to do something similar, but your example seems incomplete to me. I have the built in UserID and a Role Based ID. I need to put them together so when i query the database i can get both the logged in UserID and the ID of that unique role.
i.e. UserID: 59 and TalentID: 11
I can always get UserID with the built in function. I need to tie the TalentID to that users profile.
The Goal is: Have a logged in user be able to see anyones profile, but only edit their own profile. My intention is to use this UserID & TalentID combination as the combined key for that activity. i.e. if the user is the logged in user and the profile they are viewing is their own then they can edit, but otherwise they can only view. etc.....
I'm fairly new in outsystems so any explicit steps you have are appreciated.