I already use multiple keys in the relationship. I use contactid and a global set to 1, 2, 3, or 4 - depending on the kind of address it is: Office, Home, Second Office, Second Home…
I’ve tried every combination possible running from the onShow or a separate method from the parent/base form or running from a method or onShow in the tabpanel of the child form (obvioulsy reversing the relation).
what I was trying to say is to NOT use addFoundSetFilterParam on a related foundset.
You should let the relation it self do the work for you.
Based on prev info your relation would look like:
CONTACTS contact_id~gUser_id~gaddresstype :: ADDRESSES contact_id~user_id~addressType
When using this relation on the tabpanel , the proper related records will already show up without any scripting
I need to make a addFoundSetFilterParam that limits the view of our contact database for a specific purpose. Our contact database contains people from several dept’s and the relation is as follows:
addFoundSetFilterParam is only supported on columns of the foundset table.
I think best way to go would be scripting the SQL query on pk’s, which you can use again to load a foundset.
pseudocode
dataset = databasemanager(…do query returning pk’s)
loadRecords(dataset)
method A
var success = controller.addFoundSetFilterParam('customerid', '=', 'BLONP');
controller.loadAllRecords();
Works on any form based on the table…unless you use a useSeparateFoundSet.
It only works with the search options of Servoy itself.
But it doesn’t work anymore when after method A you use this method
Method B
var query = 'SELECT customerid FROM customer WHERE customercity LIKE 'Whatever%';
var dataset = databaseManager.getDataSetByQuery('assyst', query, null, -1);
controller.loadRecords(dataset);
Becoz according to the tutorial it says that the only way to remove controller.addFoundSetFilterParam on a form is going to designer-mode.
I found out if you run this code after Method A
var query = 'SELECT customerid FROM customer WHERE customercity LIKE 'Whatever%';
var dataset = databaseManager.getDataSetByQuery('assyst', query, null, -1);
controller.loadRecords(dataset);
controller.sort('customerid desc');
it returns a foundset that is true for controller.addFoundSetFilterParam and the query.
This is EXPECTED behaviour - and is really a feature (I think, anyway).
Why? Becuase when you use a foundsetFilterParam and you load records into the current foundset (with controller.loadRecords) - and you sorted by PK - then you “trigger” the filter.
When you don’t sort by PK and you load the records into the foundset - it just loads the records. In effect, you’ve “overridden” the filter.
Check the “move sample” on load records - and you’ll see that one of the examples is loading the recordset via a sql query - and you’ll see that an “order by” clause is required.