# Restricting records displayed in form

**URL:** <https://forum.servoy.com/t/restricting-records-displayed-in-form/2206>\
**Category:** Classic Servoy\
**Created:** [July 9, 2004, 1:00pm UTC](https://forum.servoy.com/t/restricting-records-displayed-in-form/2206 "2004-07-09T13:00:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jblarsen](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@jblarsen](https://forum.servoy.com/u/jblarsen)\
**Post date:** [July 9, 2004, 1:00pm UTC](https://forum.servoy.com/t/restricting-records-displayed-in-form/2206/1 "2004-07-09T13:00:33Z")

</div>

Greetings. New to Servoy - have done some Access and FMP development in the past.

I would like to filter out the “obsolete” parts in my table that is connected to my Servoy form - and only display (and make available for editing) the “active” parts. In Access I would write a query and base my form on that. I cannot find how to accomplish this in Servoy.

Any ideas or pointers to the place in the documentation that explains how to do this?

Regards, Jay

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [July 9, 2004, 1:17pm UTC](https://forum.servoy.com/t/restricting-records-displayed-in-form/2206/2 "2004-07-09T13:17:03Z")

</div>

There is several ways: if you need a permanent “filter”, have a look at controller.addFoundSetFilterParam

If you get more specific, I can teel you more.

---

<div class="post-metadata">

**Author:** ![maarten](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@maarten](https://forum.servoy.com/u/maarten)\
**Post date:** [July 9, 2004, 1:29pm UTC](https://forum.servoy.com/t/restricting-records-displayed-in-form/2206/3 "2004-07-09T13:29:58Z")

</div>

on form level you can limit your foundset. (also when user performs a search)

When you’re in the editor, having a method opened,  
you can rightclick on a function and select/move sample code into  
your method.

//Add a filter parameter to limit the foundset permanently  
var success = currentcontroller.addFoundSetFilterParam(‘customerid’, ‘=’, ‘BLONP’);//possible to add multiple  
currentcontroller.loadAllRecords();//to make param(s) effective

---

<div class="post-metadata">

**Author:** ![jblarsen](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@jblarsen](https://forum.servoy.com/u/jblarsen)\
**Post date:** [July 10, 2004, 2:52am UTC](https://forum.servoy.com/t/restricting-records-displayed-in-form/2206/4 "2004-07-10T02:52:16Z")

</div>

Thank you both. Now I am getting going.

I have successfully filtered my foundset. Now I want to Show All Records.

I added a button to my form and attached a Method:

controller.loadAllRecords();  
elements.headerCompanyText.text = ‘cool’;//just to see if the method is working.

The text changes, however the filter is not removed and all records are not shown.

I tried adding ShowRecords() but no luck. Ideas? Thanks!

BTW - I am using the CRM database, companies form for these tests.

Jay

---

<div class="post-metadata">

**Author:** ![maarten](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@maarten](https://forum.servoy.com/u/maarten)\
**Post date:** [July 10, 2004, 8:22am UTC](https://forum.servoy.com/t/restricting-records-displayed-in-form/2206/5 "2004-07-10T08:22:26Z")

</div>

addFoundSetFilterParam sets a permanent filter after it’s been triggered.  
(you’ll need to restart in order to disable)

Have a look at the search filters in the actions list of the demo crm.  
With that approach you could do something like this:

1. put a global checkbox named “showObsolete” in the top of your list.
2. put more global search boxes in the top of your list, eg. companyFilter

filterScript:

```auto
controller.find();// start creating find request
if(globals.showObsolete==1)"// add this search parameter if "showObsolete" is checked
{
     status = "obsolete"
}
if(globals.companyFilter)// add this search parameter if something is entered
{
    company = globals.companyFilter
}
...etc...

controller.search(); //perform the find request

```

Additionally you could add an initialising script to the onLoad event (only triggers when form is loaded first time) that sets the globals.showObsolete to 0 and performs the script mentioned above.

onLoad script:

```auto
globals.showObsolete = 0
filterScript(); // perform subscript

```
