Display accounts with more than 1 role

0
Hello community, There's a simple but tricky requirement I need to implement. I need to report all the users in the app that have more than 1 role because it's not recommended for users to have more than 1 role in the app and some of them have more than 1 approved by mistake and now we need to identify which are the problematic ones. Is there a easier way to achieve this? Any ideas?
asked
1 answers
0

Hello Andreia,

It's an interesting challenge. It should be possible to do these checks via a microflow and create temporary objects where you capture this information for each account.

I think the fastest & most efficient would be to use OQL (View Entities)

https://docs.mendix.com/refguide10/oql/

Try the following

SELECT

u.Email AS Email,

u.FullName AS UserName,

COUNT(ur.id) AS NumberOfRoles

FROM Administration.Account AS u

INNER JOIN u/System.UserRoles/System.UserRole ur

GROUP BY u.FullName, u.Email

HAVING COUNT(ur.id) > 1

This query should give you what you asked for. Maybe you can try to improve the query to also display the roles list.


answered