# addFoundSetFilterParam issues

**URL:** <https://forum.servoy.com/t/addfoundsetfilterparam-issues/2907>\
**Category:** Classic Servoy\
**Created:** [October 15, 2004, 10:03pm UTC](https://forum.servoy.com/t/addfoundsetfilterparam-issues/2907 "2004-10-15T22:03:16Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Morley](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Morley](https://forum.servoy.com/u/Morley)\
**Post date:** [October 15, 2004, 10:03pm UTC](https://forum.servoy.com/t/addfoundsetfilterparam-issues/2907/1 "2004-10-15T22:03:16Z")

</div>

My solution will be hosting several clients. As users log in, I’m populating a global with their client number. From this point forward, no matter what they do, they should see only their own records. It’s been my understanding by running “addFoundSetFilterParam” the first time a table is loaded (using the “onLoad” function) my purpose would be accomplished.

Here’s the code:

```auto
var success = controller.addFoundSetFilterParam('local_client_id', '=', 'globals.current_user_client_id');
controller.loadAllRecords();//to make param(s) effective

```

I have a “Show All” button that includes “controller.loadAllRecords()” among its instructions. Counter intuitively it loads zero records. And as long as I remain in that table (any form) I cannot re-establish any records, any forms. However, I can go to a different table and then return. Now the appropriate records are loaded, no problem.

I sense I’m misunderstanding something fundamental.

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [October 20, 2004, 5:58pm UTC](https://forum.servoy.com/t/addfoundsetfilterparam-issues/2907/2 "2004-10-20T17:58:26Z")

</div>

Hi Morley,

Check on your form that on the “onShowAllRecords” property shows “DEFAULT” rather than something else.

Also, it’s a good idea to set the addFoundSetFilterParam command as part of a startup script (I put mine in as part of the login process).

Hope this helps,

Bob Cusick

---

<div class="post-metadata">

**Author:** ![Morley](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Morley](https://forum.servoy.com/u/Morley)\
**Post date:** [October 20, 2004, 6:52pm UTC](https://forum.servoy.com/t/addfoundsetfilterparam-issues/2907/3 "2004-10-20T18:52:15Z")

</div>

> bcusick:  
> Check on your form that on the “onShowAllRecords” property shows “DEFAULT” rather than something else.
> 
> Also, it’s a good idea to set the addFoundSetFilterParam command as part of a startup script (I put mine in as part of the login process).

onShowAllRecords is set to Default on all forms, mostly because I’ve yet to explore its functionality. Hadn’t really noticed it until now.

It’s been my understanding addFoundSetFilterParam needs to be called by the onLoad property the first time the table is called. Not sure where I came to that understanding. That concept isn’t in the docs under addFoundSetFilterParam.

If this is so, then I need a script for each table attached to one of the forms of that table. Then in the startup call each of these forms in turn. Am I on the right trail?

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [October 20, 2004, 7:26pm UTC](https://forum.servoy.com/t/addfoundsetfilterparam-issues/2907/4 "2004-10-20T19:26:54Z")

</div>

Right trail - wrong execution.

You NEVER need to create form-based methods to do that. Just create a global method - and refer to the form:

```auto
forms.customers.controller.addFoundSetFilterParam('xxx','=','value')
forms.invoices.controller.addFoundSetFilterParam('yyyy','=','value2')
forms.order_items.controller.addFoundSetFilterParam('zzz','=','value3')

```

Just make your global method - then locate the form(s) and double click the addFoundSetFilterParam from the CONTROLLER object of the form.

Bob

---

<div class="post-metadata">

**Author:** ![Morley](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Morley](https://forum.servoy.com/u/Morley)\
**Post date:** [October 20, 2004, 11:39pm UTC](https://forum.servoy.com/t/addfoundsetfilterparam-issues/2907/5 "2004-10-20T23:39:53Z")

</div>

Thanks again. What about the call to controller.loadAllRecords() mentioned in the docs?

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [October 21, 2004, 6:26am UTC](https://forum.servoy.com/t/addfoundsetfilterparam-issues/2907/6 "2004-10-21T06:26:54Z")

</div>

Yes, do that after each controller.addFoundSetFilterParam() call.

Bob

---

<div class="post-metadata">

**Author:** ![olivier\_melet](https://avatars.discourse-cdn.com/v4/letter/o/ba8739/32.png) [@olivier\_melet](https://forum.servoy.com/u/olivier_melet)\
**Post date:** [October 21, 2004, 8:57am UTC](https://forum.servoy.com/t/addfoundsetfilterparam-issues/2907/7 "2004-10-21T08:57:28Z")

</div>

> It’s been my understanding addFoundSetFilterParam needs to be called by the onLoad property the first time **the table** is called.

Hi everybody,  
This just to point out that on my experience, addFoundSetFilterParam is not acting on a table, but on the form foundset.  
Thus, if you have several forms pointing on the same table, but having separate foundsets, you will have to call addFoundSetFilterParam for each separate foundset, not necessary with the same filter, which is actually a great feature.

---

<div class="post-metadata">

**Author:** ![Morley](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Morley](https://forum.servoy.com/u/Morley)\
**Post date:** [October 22, 2004, 12:59pm UTC](https://forum.servoy.com/t/addfoundsetfilterparam-issues/2907/8 "2004-10-22T12:59:38Z")

</div>

> This just to point out that on my experience, addFoundSetFilterParam is not acting on a table, but on the form foundset.  
> Thus, if you have several forms pointing on the same table, but having separate foundsets, you will have to call addFoundSetFilterParam for each separate foundset, not necessary with the same filter, which is actually a great feature.

Would appreciate having Olivier’s observation confirmed and clarified. I’ve been under the distinct understanding that once the filter is evoked, it applies in all circumstances until Servoy is rebooted and the function is called again.

If Olivier is correct, that addFoundSetFilterParam only applies to the current foundset, then the function would have to be called every time a new foundset is established. If true, then significantly different coding strategies for what I’m attempting are required.

Feeling rather wobbly in my understanding here.

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [October 22, 2004, 2:22pm UTC](https://forum.servoy.com/t/addfoundsetfilterparam-issues/2907/9 "2004-10-22T14:22:26Z")

</div>

Morley,

NO NEED TO PANIC! ![:D]( "Very Happy")

He is talking about FORMS. The addFoundSetFilterParam works on individual CONTROLLERS (not TABLES). So, if you have:

Form 1 - based on customers table

Form2 - based on customers table (but have “useSeparateFoundSet” property checked

Then - you would have to set the addFoundSetFilterParam on BOTH forms since they use separate found sets.

Bob

---

<div class="post-metadata">

**Author:** ![Morley](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Morley](https://forum.servoy.com/u/Morley)\
**Post date:** [October 22, 2004, 3:24pm UTC](https://forum.servoy.com/t/addfoundsetfilterparam-issues/2907/10 "2004-10-22T15:24:08Z")

</div>

Not panicing (or at least I hope I’m not) but I’m coming to the conclusion that something I thought was simple, straightforward and clearly understood now isn’t. So before I write code based on erroneous assumptions I want to get really clear.

Your comment about the useSeparateFoundSet property leads me doubt my understanding of foundsets.

Coming from an exclusively FMP background, I’m used to the current set of records varying constantly through the use of the Go to Related Record (GTRR) and Find commands, then returning to all records.

Until this exchange I’ve been assuming SQL’s foundset amounts to same thing – the currently loaded set of records, i.e. is constantly in flux. Now I’m not so sure.

Here’s my current confusion. When I do a Find using a method based on a particular form, it loads the results into that form. If I jump to another form based on the same table I DON’T see the same set of records (as FMP does when switching layouts) but rather the set of records that were current to that form the last time it displayed. Each form has its own independent foundset.

In other words, it would appear the useSeparateFoundSet function is turned on for all forms by default – the opposite of the docs for this function.

In other words, I’m misunderstanding something fundamental. Hope I’m explaining my muddle clearly enough.

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [October 22, 2004, 3:31pm UTC](https://forum.servoy.com/t/addfoundsetfilterparam-issues/2907/11 "2004-10-22T15:31:24Z")

</div>

Morley,

You are correct in your assumptions (basically). A “foundset” is constantly in “flux”. The addFoundSetFilterParam will ALWAYS “filter” the FOUND SET on a form.

When you have more than one form based on the same table (2 forms based on the customers table) - a find in EITHER of the forms will still be filtered. This is because the foundsets are “in synch”. This is the same behaviour as in FMP 7.

Now, you have the OPTION of checking a chedkbox that says “useSeparateFoundSet”. Again, this is similar to FMP 7.

The “useSeparateFoundSet” appears on each FORM. If you DO CHECK IT - then you will need to apply the addFoundSetFilterParam to that foundset AS WELL - since it will be “disconnected” and treated as a separate found set.

Hope this helps,

Bob
