Filter Table based on Role. Anonymous and Registered problem

Hello, I have a problem. First, I want to make  a filter table based on what Role the users are. This is the example condition filter

But the problem is when I use an anonymous and registered other user role, The table not shown.

Do you have any idea to solve this?
Thankyou in advance

Solution

hi Jason, 

does that mean that you want the following use cases: 

As an admin user I want to see movies having year >= 2000 (I missed the equal sign in your aggregate to support the year 2000)
As an adminUnder user I want to see movies having year < 2000
As another user I want to see all movies.
and perhaps As a user with admin and adminunder role I want to see all movies.

you can accomplish that with the following filter:

// show movies with year >= 2000 for Admins
CheckAdminRole() and Movie.Year >= 2000 or

//  show movies with year < 2000 for AdminsUnders
CheckAdminUnderRole() and Movie.Year < 2000 or

// show movies for users without those roles
not (CheckAdminUnderRole() and CheckAdminRole()) or

// show movies for users with admin and AdminUnder 

RoleCheckAdminUnderRole() and CheckAdminRole()

Hi Jason,

what do you mean with 'the table is not shown', that it is empty like in the screenshot? 

The aggregate only returns results if the User has the AdminRole or AdminUnderRole.

So, if you want to see data, you need to grant one of these roles to the user, which you can do in the User application.

Regards Hans

Hi, thankyou for the answer


So, how if I want to show the full data of the table if they are a registered and anonymous? Besides that the Admin is filtering the table and AdminUnder filtering the table too.

Solution

hi Jason, 

does that mean that you want the following use cases: 

As an admin user I want to see movies having year >= 2000 (I missed the equal sign in your aggregate to support the year 2000)
As an adminUnder user I want to see movies having year < 2000
As another user I want to see all movies.
and perhaps As a user with admin and adminunder role I want to see all movies.

you can accomplish that with the following filter:

// show movies with year >= 2000 for Admins
CheckAdminRole() and Movie.Year >= 2000 or

//  show movies with year < 2000 for AdminsUnders
CheckAdminUnderRole() and Movie.Year < 2000 or

// show movies for users without those roles
not (CheckAdminUnderRole() and CheckAdminRole()) or

// show movies for users with admin and AdminUnder 

RoleCheckAdminUnderRole() and CheckAdminRole()

Hi,  You're right about this point

As an admin user I want to see movies having year >= 2000 (I missed the equal sign in your aggregate to support the year 2000)
As an adminUnder user I want to see movies having year < 2000
As another user I want to see all movies.

I tried ur solution but instead of filtering, the admin and adminunder give all the data not filtered

Is there anything wrong about my filter code?

 

mvp_badge
MVP

Hi Jason,


Your condition is just missing some parenthesis and you have an and that should be replaced by an or.

Try:


not (CheckAdminUnderRole() or CheckAdminRole()) or (CheckAdminRole() and Movie.Year > 2000) or (CheckAdminUnderRole () and Movie.Year < 2000)


Kind Regards,

João

Hi Thankyou for your answer. It really helpful


I realized that I missed a parenthesis
I tried

(not (CheckAdminRole()) and not(CheckAdminUnderRole())) or

and it works.

Thankyou for your respond once again 

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