How to use the Role of the (session) user to filter a list of items in a data grid

0
Hi, I want to create the following: a have a list of items in a data grid. In the entity I have added an attribute 'Role' which is now a string. I only want the items to be shown, if this Role is the same as the Role from the current user, which is stored in System.User/System.UserRoles/System.UserRole/Name. I have tried this in several ways: referring to $currentUser and [%CurrentUser%] in the Xpath constraint of the data grid using a microflow as input for the data grid creating another string attribute in the entity and trying to keep that in sync with the role of the user However, all of this didn't work out. Thanks in advance and regards, Frank
asked
2 answers
1

Saving things as string attributes is not the best way to do this: you should just create an association between your entity and System.UserRole. Then, you can create an XPath constraint on the datagrid Entity[Entity_UserRole/UserRole/UserRoles = '[%CurrentUser%]']

The advantage of this is that it supports a many to many relation between your entity and user roles and it supports a user having multiple user roles.

If you are determined to use a string attribute, then you could use a data source microf]low where you retrieve the UserRole of the current user (UserRole[UserRoles = $CurrentUser]) and retrieve Entity[userRoleString = UserRole/Name] and return that list.

answered
0

Thank you for your quick response! I have managed to link my entities to user role and to show them only when the user has that role. The only reason I was using a string was that the UserRole/Name attribute is also a string, but your approach is way better!

answered