Uni Selector with filter users roles

Faris Rjoub asked on April 28, 2017 23:50

Hi, I tried to add form control with uni selector field based on "CMS.Users" object type. I need to open the selector with only users in specific role . Not to show all users.

How can i write "Where condition" to join users with role class.(I also tried "isinrole")

Also , I checked out the thread below: https://devnet.kentico.com/questions/user-selector-form-control-filtering-by-role-or-department

but no chance until now.

any help will be appreciated. Thanks

Correct Answer

Development Support Avastonetech answered on May 1, 2017 13:26

The where condition would be as follows:

UserID in (Select UserID from CMS_UserRole where RoleID in (Select RoleID from CMS_Roles where RoleName = 'TheRoleName'))

Having SQL management studio can help a lot in writing queries as you can see the table structure, but if all else fails you can also look in "Modules" section of Kentico and try to find the module that houses the User-Role classes so you can see the database tables and such.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Faris Rjoub answered on May 1, 2017 17:26 (last edited on May 1, 2017 17:30)

Hi , Great , its works fine. thanks.

Can we add second class in "object type" setting to be "cms.User and cms.Role" in order to return Role Name in "Return column name" setting.!!?

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on May 1, 2017 18:11 (last edited on May 1, 2017 18:12)

That should be under the Uni Selector option "Display Name Format" in conjuction with the Additional Columns which you can reference in the Display Name Format. You can include RoleID in the additional columns and make a macro to get the name from it, otherwise you can also use the Additional Columns to add in the RoleName itself

(Select top 1 RoleName from CMS_Role where CMS_Role.RoleID = RoleID) as RoleName

That should pull it in, then use the RoleName in the display name format i believe...

0 votesVote for this answer Mark as a Correct answer

Faris Rjoub answered on May 1, 2017 21:59 (last edited on May 1, 2017 21:59)

Thanks Trevor.

I will give it a try.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.