addTableFilterParam and removeTableFilterParam

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

addTableFilterParam and removeTableFilterParam

Postby Bernd.N » Wed Feb 03, 2016 3:36 pm

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.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 497
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: addTableFilterParam and removeTableFilterParam

Postby jdbruijn » Wed Feb 03, 2016 4:58 pm

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.
Jos de Bruijn
Welcome CCS
Servoy Certified Developer
Image
jdbruijn
 
Posts: 465
Joined: Sun Apr 11, 2010 6:34 pm

Re: addTableFilterParam and removeTableFilterParam

Postby Bernd.N » Wed Feb 03, 2016 5:57 pm

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.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 497
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: addTableFilterParam and removeTableFilterParam

Postby steve1376656734 » Thu Feb 04, 2016 9:44 am

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
Steve
SAN Developer
There are 10 types of people in the world - those that understand binary and those that don't
steve1376656734
 
Posts: 199
Joined: Fri Aug 16, 2013 2:38 pm
Location: Lanzarote

Re: addTableFilterParam and removeTableFilterParam

Postby Bernd.N » Thu Feb 04, 2016 10:09 am

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.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 497
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: addTableFilterParam and removeTableFilterParam

Postby jcompagner » Thu Feb 04, 2016 5:33 pm

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
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8086
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: addTableFilterParam and removeTableFilterParam

Postby Bernd.N » Thu Feb 04, 2016 6:05 pm

Thanks for the hint, Johan, we will try it soon.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 497
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: addTableFilterParam and removeTableFilterParam

Postby Bernd.N » Sun Feb 07, 2016 8:30 pm

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:

Code: Select all
   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! :)
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 497
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 2 guests

cron