Aggregate : fetch users by their role not working proberly

Hello all,

I need to fetch all the outsystems users having the specific role "RAFITDev". I am using the suggested way in the outsystems forum answers by joining the User table and the User_Effictive_Role. and I am filtering selecting the role in the Roles.

but the result is not accurate. it gives me all the users having the Role id =1.

when specifying the role id as a number in the filter it is working as expected. 

I need to understand the reason for this weird behavior if anyone has any idea.

Thanks. 

Hi @Kawthar Ebrahim 

Have you published and checking out the Aggregate  results on the screen or testing in service studio? 

I think you are checking the result in service studio itself so by default the test  value may be 1 so the you are getting user role with the id 1 . Change your test value to 76 which is RAFITDev  so you can get the actual output.

Regards,

Harika. R

Thank you very much, Harika.

This is the solution. 

mvp_badge
MVP

Hi Kawthar,


This usually happens when you move the role from a module to another.

Behind the scenes, OutSystems will create another record in the role table and set the previous one with the attribute Is_Active to False.


If you join the User_Effective_Role table with the Role one, you'll see that the 76 has the Is_Active to False, so, although the users have that role, it is inactive and therefore not considered. You will have to grant the new role (the one with the Is_Active = True) to the users.


Another reason is that you have two roles with the same name on different modules. The one with the Id = 1 and the other with the Id = 76.


Kind Regards,
João

Thanks dear for your response.

please note that the role is active and I am facing the issue in all roles in the app, the filter is not correct.


mvp_badge
MVP

Have you confirmed that you don't have the role with the name RAFITDev on multiple modules and that you are choosing the one from the module you want?

Secondly, take into account that User_Effective_Role is a view that will have the roles the user has that were granted to him / her directly or by belonging to a group with those roles.

Thanks, João. The issue was because of the test values in the service studio. 

Hi @Kawthar Ebrahim 

Have you published and checking out the Aggregate  results on the screen or testing in service studio? 

I think you are checking the result in service studio itself so by default the test  value may be 1 so the you are getting user role with the id 1 . Change your test value to 76 which is RAFITDev  so you can get the actual output.

Regards,

Harika. R

Thank you very much, Harika.

This is the solution. 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.