Hi
I have dragged the User entity to my app and it has created User and User Detail. All good.
I only want to work with users with a specific role however.
I have tried adding a filter :
But I get the error 'CheckDealerUser' function cannot be executed in the database because it receives attributes from the aggregate as parameter but it doesn't have exactly an Assign node with one assignment.
Here's my function :
What am I doing wrong? What is the correct way to do this?
You can do a JOIN with Role entity.
User_Role is for roles given directly. User_Effective_Role is better as it also includes Roles given by Groups.
There you search by role. You can also filter by module id (Espace_Id) to be more specific .
Hi @Stephen Chown ,
Your current approach won’t work as expected. You’ll need to join the Users entity with the User_Effective_Role entity instead. This has come up before, and here’s a discussion with a solution that might help:
How to filter users based on a particular role?
Forgive my ignorance but ROLE and USERROLE do not seem to be available to me? Where do I find them?
They are in the (System) module. You can go to Manage Dependencies (Ctrl + Q) -> (System) and then search for these entities.
Apologies again. That brings up "Add Public Elements"
And those tables aren't there.
Are you working in ODC? The post has the wrong tags.
The last time I had to do it, I implemented Roles as extra attributes, a bit like this recent post explains.
https://www.outsystems.com/forums/discussion/103974/best-approach-for-user-management-in-odc-need-dropdown-of-users-with-extra-detai/
Yes ODC Studio. I thought I had tagged it correctly.
Hi @Stephen Chown
In ODC, it's not possible to achieve this directly in the way you're suggesting. If you want to use the Users Table, you would need to create a Server Action with an aggregate and a loop to check user roles. However, keep in mind that the Users Table is not the same as what you see in the ODC Portal. More details here:
https://www.outsystems.com/forums/discussion/89157/how-to-get-user-with-role-in-odc/
For your use case, it can be better to use the User and Access Management API. Documentation here:
https://success.outsystems.com/documentation/outsystems_developer_cloud/odc_rest_apis/user_and_access_management_api/
I see two possible approaches for your use case.
1. Use a Data Action to build a local list of users with the role. Iterate through the users and check their roles in a For Each loop.
2. Create a separate UserRoles entity and use the API to fetch each user’s application roles. You can then schedule a timer to keep this entity in sync.