How to capture UserID on a form and have it carry over to multiple screens

I am using GetUser(GetUserId).User.Name to capture the user when requesting work on my web application. Unfortunately when I go to a page I am developing that shows all requests and who requested them it is displaying all requests from the user that is viewing them. 


How do I capture the user when they make the request so that when you view the request page you can see who made each individual request? 

Hi Brett,


I don't know if I understand your question.

1. I think you need an attribute in your entity to store the user ID of type User Identifier

2. When a particular user creates a new record, you must populate this new attribute with GetUserId() (which returns the logged in user ID).

3. Once that is done, you can add the User entity to aggregate, and join through the attribute you created, and on your screen display the information directly from the aggregate result.

Or you can change GetUser(GetUserId).User.Name to GetUser(YourAggregate.Entity.NewAttribute).User.Name


Regards

So I am using GetUser(GetUserId()).User.Name on my screen that notifies a user when they successfully submit a request. 


I want that user information to then be displayed on a queue page I made for customers to check on the status of their requests. So there is a search option they can filter down to the requests that they made. Does that make more sense? I tried your method above but I am getting an error page on the queue page when I use GetUser(GetUserId.Entity.NewAttribute).User.Name. The entity attribute I made is titled GetUserID. 


Hi Brett,


GetUser(GetUserId.Entity.NewAttribute).User.Name is wrong, you need to replace this content "GetUserId.Entity.NewAttribute" with the name of your tablerecord, with the name of your entity, and finally the name of your new attribute.


Example:

The name of my entity is Request,

The name of the attribute is RequestedBy (the type is User Identifier)

The name of the TableRecord is RequestsTableRecord


so the result will be like this:

GetUser(RequestsTableRecord.Request.RequestedBy).User.Name

Pedro Costa wrote:

Hi Brett,


GetUser(GetUserId.Entity.NewAttribute).User.Name is wrong, you need to replace this content "GetUserId.Entity.NewAttribute" with the name of your tablerecord, with the name of your entity, and finally the name of your new attribute.


Example:

The name of my entity is Request,

The name of the attribute is RequestedBy (the type is User Identifier)

The name of the TableRecord is RequestsTableRecord


so the result will be like this:

GetUser(RequestsTableRecord.Request.RequestedBy).User.Name

Okay so I think I know what the issue is. I have that GetUser(RequestsTableRecord.Request.RequestedBy).User.Name correct, but I am not caputuring the data correctly as it is just a 0 on my table. I think once I figure out how to capture the login information and have it save to my data table I should be able to get it working.


Yes ! Now you have to modify your action when creating the record in your entity by filling in the new attribute you created with GetUserId().


From there the new records will have the field filled with the user ID that was logged in.


Regards

You should note that when using the native outsystems Get API, if the value you pass to this function is NullIdentifier(). Will throw an exception

To avoid this behavior, I suggest changing your aggregate by joining your entity with the Users entity. And after that you no longer need to use GetUser function on your tablerecord, and simply use the Users.Name attribute.

Pedro Costa wrote:

You should note that when using the native outsystems Get API, if the value you pass to this function is NullIdentifier(). Will throw an exception

To avoid this behavior, I suggest changing your aggregate by joining your entity with the Users entity. And after that you no longer need to use GetUser function on your tablerecord, and simply use the Users.Name attribute.

So when I do GetUserId() I get a number that fills up the space instead of my name. The other thing too I noticed is my data table is still not being populated with the user ID data. It just has a 0 still. 



Hi,


GetUserId() returns the identifier of the user that is currently authenticated.


You need fill the attribute of your table with the ID of the user currently authenticated. If your logic of creation is inside of a timer, timer don't have session, and the result of GetUserId() is null.