addFoundSetFilterParam

I have this added to the onload event of a form using a separate foundset. The form is not loading any records.

Are there any instances where this filter will not work?

forms.defect_lst_template.foundset.addFoundSetFilterParam('is_template','=','1');
forms.defect_lst_template.foundset.clear();

I assume you expect these lines of code to directly filter the table and load the records that match the filter?

This isn’t the case, this filter is added to your foundset’s rules.
So for example if you do a find on this ‘template’ table on let’s say the field ‘name’.
Without a filterrule, your find could return records where the field ‘is_template’ != 1.
With the filterrule applied Servoy will add the SQL that matches the filter to the background SQL that’s generated from the find example above.

I hope this shed some light on the filterfunction.

To be a bit more complete: you can easily add ‘controller.loadAllRecords()’ to your onLoad method.
This will loadAllRecords matching the filter you’ve set.

but you do clear() why should it then load records? I guess you want to call loadRecords instead to get the records filtered by the filter param

forms.defect_lst_template.foundset.addFoundSetFilterParam('is_template','=','1');
forms.defect_lst_template.foundset.loadRecords();