How to check if User id is present or not in User Entity

Hello Team,



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

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

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

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)

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

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

You can try something like that:

GetUser(GetUserId()).User.Name

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


Regards!


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. 

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?

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.

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.


Hi Afaque,

You can put it like below.

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


cheers....


Hi

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


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.