Display User Roles on Application Users Datagrid

Hello,

I am using default security and would like to display an aggregated comma separated string of the user's roles in a column on the Application User page just as they are displayed in the Add and Edit Application User forms shown below:

image

I see the Application Users page has a default array of RoleNames which I have tried using in a column template with the string.join method but have been unable to get it to display as desired.

Is there another method I should be using?

Thank you,

Zach

Hi @Zach.E,

You are right, the RoleNames property of the user is not populated. We will release fix for this in our next update later today! Here is an example expression that will work properly in our next build: ${string.Join(",", Security.User?.RoleNames ?? Enumerable.Empty<string>())}

1 Like

Thank you @enchev, RoleNames is indeed populated and the code you provided does display all available role names, but I would like to display the role names related to a specific user in the Application Users table. I thought this may be achievable using string.join and data.RoleNames but I was unsuccessful.

Is there a way to do that?

Thanks,

Zach

Hi @Zach.E,

If you want to get specific user and the user roles you can use GetUserById() method of the security service:

This is how EditApplicationUser page works, you can check the code in Page Load.

You have to leave the Property value EMPTY. This is for binding only.

Write the code, the @enchev mentioned, to the TEMPLATE property

image