We need to show users only part of the data, e.g. a department manager may only see the projects from her own department.
That can be efficiently done with
databaseManager.addTableFilterParam(scopes.utils.DB.SERVER, 'projects', 'department_id', '=', scopes.person.currentUserDepartmentID, 'projectsFilter');
Unfortunately, that department manager sometimes is the project leader of a project that runs in another department. So she needs access to that project, too.
With the table filter above, this can not be done.
A solution is to create an array _aProjects of all PKs of the project records where the user needs access. Then the filter condition is like this:
databaseManager.addTableFilterParam(scopes.utils.DB.SERVER, 'projects', 'project_id', 'in', _aProjects, 'projectsFilter');
This solution seems to have the disadvantage that it slows down database operations considerably, e.g. the saving of a project element needs now 45 seconds instead of 2 seconds.
I have to admit that the number of projects in the _aProjects array is quite large for some department managers, as we took over 10 years of old data.
My current idea is to reduce the size of _aProjects to only those records that are currently running (open), so that all 10.000 old projects from the past do not appear in the list any more, and do not cause bad performance.
Did anybody have a similar situation in filtering data?
I would be interested if there are other solutions or ideas than the "project_id IN array" - filtering which seems to slow down the server a lot, when the array is large.
One idea: Is there a way to connect several addTableFilterParam with "OR" ?
It should result in this filtering operation of Servoy:
(department_id = scopes.person.currentUserDepartmentID OR department_id IN <very small list of additional PKs>)
You can issue several addTableFilterParam for one table, but as far as I know they are then always connected with AND.