486
Views
13
Comments
How to check if User id is present or not in User Entity
Question

Hello Team,



I want to check if user id is present then show user name in a expression else show '-'.

2025-11-19 06-14-01
Miguel Verdasca
Champion

Hi,

What you want depends on use case to use case. Without knowing great promeners, you will get the current user id through GetUsetId (), and query the users table, if there is a match is because there is the name.

But as I told you, I give this suggestion without knowing great details of what you want.

I hope this help you.

Cheers,
Nuno Verdasca

2021-10-17 12-36-16
Amreen Shaikh

Afaque Shaikh wrote:

Hello Team,



I want to check if user id is present then show user name in a expression else show '-'.


Hi Afaque,r

Solution1.

Use filterlist

OR

Solution2.

Take aggregate of User entity.

then take for loop to iterate the aggregate list.

Hope this will help you.


Regards,

Amreen

UserImage.jpg
Pratham Polekar

Hi Afaque Shaikh,

You can use if widget on UI where you want to show user details.

if GetUserId() <> NullIdentifier()

true

GetUser(GetUserId()).User.Name (in expression)

false

"-" (in expression)

UserInfo.JPG
2021-03-05 13-56-11
Ricardo Pereira
Ā 
MVP

Hi Afaque,


First of all, you're developing tradicional web, reactive or mobile? You have diferent solutions for each of the scenario, and some solutions work in one scenario and not in others.

Can you give us more details?


Best regards,

Ricardo

UserImage.jpg
Afaque Shaikh

Ricardo Pereira wrote:

Hi Afaque,


First of all, you're developing tradicional web, reactive or mobile? You have diferent solutions for each of the scenario, and some solutions work in one scenario and not in others.

Can you give us more details?


Best regards,

Ricardo


Its a web App.

Thank you

2025-11-19 06-14-01
Miguel Verdasca
Champion

You can try something like that:

GetUser(GetUserId()).User.Name

(Built-in Functions -> Roles -> GetUserId())


Regards!


UserImage.jpg
Afaque Shaikh

Hello,


SyntaxEditor Code Snippet

GetUser(XYZTable.List.Current.EntityWhichHasUserId.UserId).User.Name

I want to check if record of EntityWhichHasUserId.UserId is present in User Entity, if yes then show user name else show "-".

Hope its clear now. 

UserImage.jpg
Pratham. Polekar

Afaque Shaikh wrote:

Hello,


SyntaxEditor Code Snippet

GetUser(XYZTable.List.Current.EntityWhichHasUserId.UserId).User.Name

I want to check if record of EntityWhichHasUserId.UserId is present in User Entity, if yes then show user name else show "-".

Hope its clear now. 


You are checking it on UI or in screen/server action?

UserImage.jpg
Afaque Shaikh

Pratham wrote:

Afaque Shaikh wrote:

Hello,


SyntaxEditor Code Snippet

GetUser(XYZTable.List.Current.EntityWhichHasUserId.UserId).User.Name

I want to check if record of EntityWhichHasUserId.UserId is present in User Entity, if yes then show user name else show "-".

Hope its clear now. 


You are checking it on UI or in screen/server action?

On UI.


Thank you.

2025-11-19 06-14-01
Miguel Verdasca
Champion

Afaque Shaikh wrote:

Pratham wrote:

Afaque Shaikh wrote:

Hello,


SyntaxEditor Code Snippet

GetUser(XYZTable.List.Current.EntityWhichHasUserId.UserId).User.Name

I want to check if record of EntityWhichHasUserId.UserId is present in User Entity, if yes then show user name else show "-".

Hope its clear now. 


You are checking it on UI or in screen/server action?

On UI.


Thank you.

Did you see my last answer?

Because, It's the same answer as it is here and I'll point you where you can go for action.


UserImage.jpg
Pratham. Polekar

Hi

I hope there is mapping between EntityWhichHasUserId Table and Outsystems User Table.(EntityWhichHasUserId.UserId data type is User Identifier)


2020-06-27 18-35-53
Rohan Hanumante

Hi Afaque,

You can put it like below.

If(EntityWhichHasUserId.UserId <> NullIdentifier(), GetUser(XYZTable.List.Current.EntityWhichHasUserId.UserId).User.Name, "-");


cheers....


UserImage.jpg
Afaque Shaikh

Rohan Hanumante wrote:

Hi Afaque,

You can put it like below.

If(EntityWhichHasUserId.UserId <> NullIdentifier(), GetUser(XYZTable.List.Current.EntityWhichHasUserId.UserId).User.Name, "-");


cheers....


Hello Rohan,

There is mismatch in a User Entity and EntityWhichHasUserId. EntityWhichHasUserIdhas  have user ids which does not exist in User Entity.

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