How to get a label from a entity based on username entered from a previous screen?

Hi Community,


I have a screen for user to enter their username and bring that input parameter to the next web screen.

My case is when user is not logged in and fill in form for some validation.

This snippet is used to pass the username to the new webscreen.


GetUser(userId).User.Name


I need to get an expression based on the username.

I not sure should i pass the id of the record from the previous screen or use a expression to get the label from the record.

May i know how to get a label from entity record base on the username on the new webscreen when passed from the previous web screen?


Best Regards,

Wen Kai


Hello Wen,


I'm not sure I understood your question, however the best way is to pass the Id, and then in the preparation of the that screen, drag the Users aggregate and filter for "User.Id =UserId" and then you get the info of the user of the previous screen.

You can always get the userId of the user that is logged in with the fuction "GetUserId()".

After that you can use the aggregate of the preparation to your expression in the screen toi get the name of the user.

See the images.


Hope this helps,


MP


Hi Wen,

Sounds like you try to rebuild the existing login logic from OutSystems?

You should check the logic on the screen Login in the Common UI flow of your application.

There you find your answer.

Regards,

Daniel

@Miguel: if you drag the UserId Input Parameter instead, Service Studio will create the filter for you! :)

Hi Miguel Palrão,


Thanks for prompt replies:)


Sorry for not explaining carefully, my case is for user does not login

The web screen that user enter is validation form for user to enter their username to check their username whether exists anot.


Hi Daniël Kuhlmann,

Sounds similiar, but my case is the expression change depends on the user enter on the previous screen.

I can pass the user id and username to the next screen.

The expression is based on the user id and username.

I not sure how to go about doing this.


Hi Kilian Hekhuis,

I didn't know this function is in service studio.


Best Regards,

Wen Kai



Hi Wen,

Maybe you are looking for something like this? (see oml attached)

However you don't need to go to a different screen to see if the user exists, you can do the validation in the submit button and print a message on the same screen.

Or just use the login screen from Outsystems :)

Hope this helps,


MP


Hi Miguel Palrão,


Sorry for the late reply.

I have take a look at your oml. Thanks for sharing the oml.

My scenario after user enter their username, the next page will show some details to verify their identity.

It is use for verifying their details.

Next screen will show some details that user register have keyed in the details.

I not sure how to get details of the user based on that username input from the previous screen.

May i know any method to get the details base on username through expression?


Best Regards,

Wen Kai


Solution

Hi Wen,

So what you can do is pass the username through an input parameter and in the preparation filter for username in the aggregate and you will get the details of the user that you are looking for, in that page.


Best regards,

MP


Solution


Hi Miguel Palrão,


I did use the method you recommend.It works !

Thank you for being a great help!


Best Regards,

Wen Kai

Never use built-in GetENTITY(EntityId) action, unless you're very sure it will get the record.

If the EntityId is null or incorrect, it will generate an exception, and that exception will bring Internal Error page with no error explanation (you need to see in ServiceCenter).

Harlin Setiadarma wrote:

Never use built-in GetENTITY(EntityId) action, unless you're very sure it will get the record.

If the EntityId is null or incorrect, it will generate an exception, and that exception will bring Internal Error page with no error explanation (you need to see in ServiceCenter).

Hi Harlin Setiadarma,


Thanks for the helpful advice.

Is GetENTITY(EntityId) action insecure or the record might become null?


In my service center, i got this error with key 0 was not found.

I think it pass a null identifier causes this error.


Best Regards,

Wen Kai


Harlin Setiadarma wrote:

Never use built-in GetENTITY(EntityId) action, unless you're very sure it will get the record.

If the EntityId is null or incorrect, it will generate an exception, and that exception will bring Internal Error page with no error explanation (you need to see in ServiceCenter).


Or if you do have to use GetEntity then certainly put an If condition around it to handle null EntityIDs example: If(not(EntityId=NullIdentifier()), GetEntity(entityid), "")

It's not insecure, but it can produce exception that will show users that nasty internal error page.

@Sam Long: that can work if you're very sure your id is valid/exists on that entity.

GetENTITY will throw error/exception when record not found.