We’ve got the following code in a method that is called when a solution loads (via File > Solution Settings > On Start Method):
var serverName = “peer”; // Note you can’t use controller.getServerName() becuase that loads a recordset which is unfiltered by default. Hard coded here, no global variable used.
var filters = new Array(26);
filters[0] = databaseManager.addTableFilterParam(serverName, ‘panels’, ‘id_panels’, ‘!=’, 0);
filters[1] = databaseManager.addTableFilterParam(serverName, ‘people’, ‘id_people’, ‘!=’, 0);
…
We’re filtering out a single records from lots of tables (very, very useful), and this seems to work fine in Client, but the filters do not always seem to apply in Developer and we often see the filtered record when working. It’s not a huge problem, but seems to be an error and is confusing as we expect those filtered records to be banished.
Old thread, but I hit similar problems and wanted to share what I learned…
I was trying to apply two separate addTableFilterParam’s to the same table (2 separate lines, filtering on different fields). I got very random results between Develepor and Client, and often it wouldn’t do any filtering at all, even if the result returned TRUE that the filter had been applied successfully.
var result1 = databaseManager.addTableFilterParam('lincage_data', 'wo_header', 'wo_status_id', '>', 1)
var result2 = databaseManager.addTableFilterParam('lincage_data', 'wo_header', 'field_rep', '=', globals.gLoginRepId)
I saw this thread that said the filters weren’t being applied in developer, but were in Client.
So after much head banging and lots of testing, I finally figured out the answer…
Once you apply a filter in Developer, that filter can stick, even if you go in and out of Designer/Run mode. You must restart Developer completely to clear out filters. At least that’s what I found that fixed it. I kept changing my code, but the filtering wouldn’t work. After a restart, it works as expected.
I hope this saves someone else some headaches. These filters are awesome --when they work!
In Servoy 4 table filter params functionality has been improved, is are more flexible now.
Before, a table filter param had to be added before forms have been loaded and could not be removed.
If a form was already loaded, adding a table filter param had no effect to the specific form which could cause confusing behaviour.
In Servoy 4, table filters can be applied at any time and are immediately effective for all forms on the table, whether instantiated or not.
When the table filter is given a name (a new additional parameter to addTableFilterParam) they can be removed as well using removeTableFilterParam.
I’m having problems with addTableFilterParam again.
It works on one table in my solution, but not another.
I have an onOpen method that runs first and this is the first line:
var result = databaseManager.addTableFilterParam('user_data', null, 'team', '=', 1)
Result always returns true, as if it succeeded, but nothing is ever filtered on this one table. I’m not loading any forms and accessing any tables or foundsets prior to running this.
The table I’m trying to filter has a field named “team” which is an INT. Database is MySQL 5.0. No matter what I’ve tried, I always get all records. I have restarted developer many times, tried smart client and web client, and this fails to work in all cases.
I have also tried other fields in the same table and none of those will filter either. I have dropped the table, recreated it, changed the character set, etc, etc. All to no avail.
I have also looked in the Mysql log and there is no “where” clause when it fails. When I put it on another table where it works, I can see the “where” clause in the logs.
Servoy doesn’t like my table for some reason.
FYI: addFoundSetFilterParam works fine on this table (although I don’t prefer to do it this way)
Can you create a small sample solution that shows the problem?
Please create a case in our support system and attach the sample (or your solution if the sample works as expected)