We want to be sure that users see only the records (in this case projects) they are allowed to see.
So we create an array _aProjects with the recordIDs the user has access to, and then we use
databaseManager.addTableFilterParam(scopes.utils.DB.SERVER, ‘projects’, ‘project_id’, ‘in’, _aProjects, ‘projectsFilter’)
for the user.
Now in the time booking module, we have the situation that users should book to projects that they are not allowed to see fully.
However, we need to show the project name of those projects, for example, and also the projects have to be in full reach for the user as he will book time and costs directly to them.
To solve this dilemma, we use databaseManager.removeTableFilterParam(scopes.utils.DB.SERVER, ‘projectsFilter’) in the onShow() of the timeBookingModule,
and then we call the above addTableFilterParam() again in the onHide(), exactly as stated above.
So we switch the tableFilter on and off, depending on which module the user goes.
Unfortunately, this works only for the first time the user goes into the timeBookingModule.
When he switches to another module and goes back (and therefore triggering the above methodes()), some project records are not there any more. Strangely enough, some project records appear and some not.
It seems as if the removeTableFilterParam() did not unlock the projects table fully, so that some records are still out of reach for the relation that should show them.
What might be the reason for this behaviour?
And has someone an idea how we could solve this in another way that will not have this problems?
To securely hide those projects from the project leaders that they should not see, a foundset.find/search-approach is in my opinion not save enough, as a foundset can always get expanded again to the complete table.
you could create a separate projects table for your timetable module where you duplicate the project name and id.
Use table events you can keep it in sync with the real projects table.
Yes, that would solve the problem that projects do not show. However users need also to book to all projects (i.e. change data in them like costs and actual hours), and that is not possible with a duplicate table.
Is it possible that whilst the user is in the other module they have filtered the projects foundset to reduce the number of records so when the table filter parameter is removed you are not revealing the entire table? if so you could try using separate foundsets for the different modules or reload the foundset in the onShow method.
Steve
Hi Steve,
that is not possible, because they even do not have access to the project module, so they can not filter them.
And even if they would have reduced the foundset of the projects in one form by filtering with find() and search(), that would not have any impact on a relation that depends on the projects, at least as I know.
We already tried this:
datasources.db.bob.projects.getFoundSet().loadAllRecords();
and
databaseManager.refreshRecordFromDatabase(datasources.db.bob.projects.getFoundSet(), -1);
but both with the result that it got worse, then no records at all showed in the form any more.
But maybe we need to refresh the relation after that, we will try to do that on Saturday.
datasources.db.bob.projects.getFoundSet().loadAllRecords();
that call is completely useless and wil not do anything
That will just create another foundset where you then call loadAllRecords on so it loads
and then it is completely discarded again.
same for databaseManager.refreshRecordFromDatabase(datasources.db.bob.projects.getFoundSet(), -1);
also useless
datasources. are for getting a foundset that you then use everywhere.
Its not the global entry for all?? foundset based on that datasource…
databaseManager.refreshRecordFromDatabase should be used to refresh the forms foundset (so that you really show in the form) or a record.relation of the record that you show
Thanks for the hint, Johan, we will try it soon.
Hi Johan,
your hint did work, we think it is a timing event, i.e. a calculation that we depend on seems to take place before the records are refreshed.
We could solve it like this:
databaseManager.removeTableFilterParam(scopes.utils.DB.SERVER, 'projectsFilter');
// -1 means everything
databaseManager.refreshRecordFromDatabase(foundset, -1);
databaseManager.recalculate(foundset);
So whenever there is a problem with records not showing after a removeTableFilterParam(), refreshRecordFromDatabase() should help.
And in case a calculation is involved, a recalculate() is needed additionally.
Many thanks, that was an important key issue for us! ![Smile :)]()