# Initial Form Foundsets

**URL:** <https://forum.servoy.com/t/initial-form-foundsets/8663>\
**Category:** Classic Servoy\
**Created:** [January 29, 2008, 4:29pm UTC](https://forum.servoy.com/t/initial-form-foundsets/8663 "2008-01-29T16:29:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgarfield](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@jgarfield](https://forum.servoy.com/u/jgarfield)\
**Post date:** [January 29, 2008, 4:29pm UTC](https://forum.servoy.com/t/initial-form-foundsets/8663/1 "2008-01-29T16:29:28Z")

</div>

Case ID: 116119

So, in the past when we have wanted a form to load with an empty foundset, we have attached a method (clearMyfoundset) to the form’s onLoad event. Currently in Servoy 3.5.3 it does not appear that this method works any longer. What I seem to see is the following order of events

1. Form gets loaded
2. Database Performance Manger indicates that a query runs selecting X number of records for that table
3. Records get loaded
4. onLoad method fires, foundset gets cleared.

This of course is undesirable because the entire point of having an empty foundset is to cut down on load times.

We have currently started to use databaseManager.setCreateEmptyFormFoundsets() as a solution for the time being, which is mostly working fine. However, in the end this is also an undesirable solution as well, because it forces ALL forms to have this property, which we weren’t previously doing. This may be a bug, but we have noticed that sometimes we will load a record into a form before navigating to it, and then after navigating to the form, the record is gone.

My feature request is this, since it appears that Servoy performs a TOP query get the records to load into a foundset, could there be a form property, something like initialRecords, that would be the number of records Servoy should load into that form when the form is first loaded? That way, it could be the default of 200, 0 if you wanted no records, or even 1, if you wanted the foundset to not be empty, but also didn’t want to load hundreds of records.

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [October 30, 2008, 1:18pm UTC](https://forum.servoy.com/t/initial-form-foundsets/8663/2 "2008-10-30T13:18:00Z")

</div>

I have also an unwanted situation when using databaseManager.setCreateEmptyFormFoundsets()

I also wanted to use the setCreateEmptyFormFoundsets because to many records are loaded.  
I have a main form with a dynamic build tabform.

onShow of my main form, I create the tabform (in the example there are fixed names, but in real all names are variables, because it is in my framework)

```auto
forms.chauffeur_tab.elements.tabs.removeAllTabs()
forms.chauffeur_tab.elements.tabs.addTab( forms.percentenboek, '', 'Percentenboek', null, null, null, null, forms['chauffeur_tab']['chauffeur_to_percentenboek']);

```

When the initial load was ON, then the correct records were shown. But since I put the initial load OFF, the relation forms[‘chauffeur\_tab’][‘chauffeur\_to\_percentenboek’] doesn’t have any records  
Since there are no parent records, there are no child records to show neither.

But when I select a record in my main form

```auto
controller.find()
chauffeur_id = 51611
controller.search()

```

I expect that the correct records on the childform are loaded. But that doesn’t happen.

So this seems a bug to me. When you define a relation for a tab, it should not matter if at the moment of creation there are records or not.  
It happens both in 3.5.7 and 4.0.1

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [November 3, 2008, 4:02pm UTC](https://forum.servoy.com/t/initial-form-foundsets/8663/3 "2008-11-03T16:02:20Z")

</div>

if you first run this if there are no records in that form:

```auto
forms.chauffeur_tab.elements.tabs.addTab( forms.percentenboek, '', 'Percentenboek', null, null, null, null, forms['chauffeur_tab']['chauffeur_to_percentenboek']);

```

and then after that this:

```auto
controller.find()
chauffeur_id = 51611
controller.search()

```

then yes you have a problem because there is no such relation so the tab is created without a relation so doesnt know how to fill it.

if you look in the debugger what is the value of: forms[‘chauffeur\_tab’][‘chauffeur\_to\_percentenboek’] ?  
i guess it is null or undefined right?

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [November 5, 2008, 9:25am UTC](https://forum.servoy.com/t/initial-form-foundsets/8663/4 "2008-11-05T09:25:28Z")

</div>

> jcompagner:  
> i guess it is null or undefined right?

Yes indeed

But this is a serious problem. A relation is defined on design time, so it should not depend on if there are records in the foundset or not.

I see lot of records selected because of the default initial load of forms (max 200 records on each form)  
And there is one way to avoid that and that is the databaseManager.setCreateEmptyFormFoundsets()

So both parent form and related form are initially empty.  
But when I select a record on my parent form, then the related form must get a correct contents.

I think that the problem is that the relation parameter in the addTab() method is not correct.

In script we must use the syntax like in the example:

forms[‘chauffeur\_tab’][‘chauffeur\_to\_percentenboek’]

but when using related tabs on designtime, then you define ‘chauffeur\_to\_percentenboek’ as relation

In my opinion the relation parameter of the addTab() method must allowed a fixed relationname (just like on design time)

So the coding should be:

forms.chauffeur\_tab.elements.tabs.addTab( forms.percentenboek, ‘’, ‘Percentenboek’, null, null, null, null, ‘chauffeur\_to\_percentenboek’);

where the relation name refers to the relation on the form that contains the tabpanel (marked in red)

In that case you are in line with designtime related tab panels

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [November 11, 2008, 3:14pm UTC](https://forum.servoy.com/t/initial-form-foundsets/8663/5 "2008-11-11T15:14:09Z")

</div>

i changed it so that you also can use relation names.

also with solution model you can do it also with relation solution objects then just before runtime.

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [November 11, 2008, 5:22pm UTC](https://forum.servoy.com/t/initial-form-foundsets/8663/6 "2008-11-11T17:22:32Z")

</div>

Will this be available in 3.5.8 also?

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [November 13, 2008, 12:50pm UTC](https://forum.servoy.com/t/initial-form-foundsets/8663/7 "2008-11-13T12:50:40Z")

</div>

yes 3.5.8 will also have it

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [November 13, 2008, 12:53pm UTC](https://forum.servoy.com/t/initial-form-foundsets/8663/8 "2008-11-13T12:53:06Z")

</div>

OK Thanks Johan.

When will 3.5.8 be released?
