Filter Browser Screen By Logged on User

Hi there,

I have two “almost” related questions:

I have an task entity that has an assignedTo field. I would like to filter the browser table to only show the tasks that have been assigned to the logged on user.

e.g. On the image below, if Collins O is logged in, he’ll only see the tasks that are assigned to him. The curve ball though is that there’s an admin who’s supposed to see all of them. The task entity is a composition of a projects entity which has an projectsManager field. If the project manager is the one logged in, then he should see all the tasks. In which case, in my example, the project manager could have a task assigned to them as well.


The second question is almost similar to that. Once I open the tasks editor, there are two checkboxes which should only be editable to the assignedTo user.


Tried this but it didn’t work:

if (getItem().getAssignedTo().getId() == AppBeans.get(UserSessionSource.class).getUserSession().getUser().getId()) {

Thanks in advance.

The second question I have been able to fix it using this code:

 if (getItem().getAssignedTo().getId().equals(AppBeans.get(UserSessionSource.class).getUserSession().getUser().getId())) {

Logic: Comparing strings in java. Check out this stack overflow question.

Still waiting for help on the first one though.

And the first one I have been able to get to it by utilizing the session filter for jpql.

select e from ppm$Tasks e
where = :session$userId

If there is a simpler or a neater way of achieving this, I’ll appreciate.

What’s remaining now is how do I allow the project manager to see all?

Hi Kenince,

You can also use security constraints to assign row-level restrictions to entities at runtime.

As for the project manager, I suppose you have a project attribute in the Task entity. Then the query could be as follows:

select e from ppm$Tasks e
where = :session$userId 
    or = :session$userId