# namedFoundSet in SolutionModel

**URL:** <https://forum.servoy.com/t/namedfoundset-in-solutionmodel/12830>\
**Category:** Classic Servoy\
**Created:** [September 8, 2010, 10:01am UTC](https://forum.servoy.com/t/namedfoundset-in-solutionmodel/12830 "2010-09-08T10:01:47Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [September 8, 2010, 10:01am UTC](https://forum.servoy.com/t/namedfoundset-in-solutionmodel/12830/1 "2010-09-08T10:01:47Z")

</div>

FormA has tab panel1 that contains form1 and tab panel 2 that contains form 2. All forms have the same data source.  
I want form1 and form2 both with separate found sets.

```auto
var formCal1 = solutionModel.newForm('cal1', 'coperta', 'actions', null, true, 240, 35);
	var headerCal1 = formCal1.newHeaderPart(20)
	formCal1.navigator = SM_DEFAULTS.NONE;
	formCal1.scrollbars = SM_SCROLLBAR.HORIZONTAL_SCROLLBAR_NEVER|SM_SCROLLBAR.VERTICAL_SCROLLBAR_NEVER;
	formCal1.borderType = 'EmptyBorder,0,0,0,0'
	formCal1.styleName = 'coperta';
	formCal1.styleClass = 'toolbar';
	formCal1.transparent = true;
	formCal1.view = JSForm.LIST_VIEW

	formCal1.onLoad = formCal1.newFormMethod('function onShow() {var frm = currentcontroller.getName();forms["cal1"].controller.loadAllRecords();var query = "SELECT usr_id FROM users WHERE usr_cal_user =1";var dataset = databaseManager.getDataSetByQuery(currentcontroller.getServerName(), query, null, 100); var vdataset = dataset; var row = new Array();forms["cal1"].controller.find(); var rangeX = "#" + globals.g_search_day_1 + "|dd-MM-yyyy"; var first = vdataset.getValue(1, 1); forms["cal1"].act_user_id = first; forms["cal1"].act_date_begin = rangeX; forms["cal1"].act_type = "2"; for(var i = 2 ; i <= dataset.getMaxRowIndex() ; i++ ){row[i] = vdataset.getValue(i, 1); forms["cal1"].controller.newRecord(); forms["cal1"].act_user_id = row[i]; forms["cal1"].act_date_begin = rangeX; forms["cal1"].act_type = "2";}forms["cal1"].controller.search();}')	

	var myFoundSet1 = forms['cal1'].foundset;
	//formCal1.namedFoundSet = myFoundSet1;

```

As soon as I call “formCal1.namedFoundSet = myFoundSet1;” it comes with a “Stale form error”

Thanks for any help

---

<div class="post-metadata">

**Author:** ![victor.rojo](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@victor.rojo](https://forum.servoy.com/u/victor.rojo)\
**Post date:** [September 8, 2010, 10:33am UTC](https://forum.servoy.com/t/namedfoundset-in-solutionmodel/12830/2 "2010-09-08T10:33:46Z")

</div>

I think that the namedFoundSet property only tells if the foundset is separate, not what foundset is used in the form. Did you try formCal1.namedFoundSet = “separate”?

---

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [September 8, 2010, 10:42am UTC](https://forum.servoy.com/t/namedfoundset-in-solutionmodel/12830/3 "2010-09-08T10:42:46Z")

</div>

Hello Victor,

> Did you try formCal1.namedFoundSet = “separate”?

Yes I’ve tried that, but it doesn’t work.

According the sample that comes with the method it is necessary to define a found set first an then give the name to the property.

```auto
var firstForm = solutionModel.newForm('newForm1', 'myServer', 'myTable', null, true, 800, 600);
	var secondForm = solutionModel.newForm('newForm2', 'myServer', 'myTable', null, true, 800, 600);
	forms['newForm2'].controller.find()
	forms['newForm2'].columnTextDataProvider = '=aSearchValue';
	forms['newForm2'].controller.search()
	var myFoundSet = forms['newForm2'].foundset
	firstForm.namedFoundSet = myFoundSet;

```

The mistake must be somewhere else… no idea where ![:(]( "Sad")

---

<div class="post-metadata">

**Author:** ![victor.rojo](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@victor.rojo](https://forum.servoy.com/u/victor.rojo)\
**Post date:** [September 8, 2010, 10:56am UTC](https://forum.servoy.com/t/namedfoundset-in-solutionmodel/12830/4 "2010-09-08T10:56:01Z")

</div>

Seeing the wiki [http://wiki.servoy.com/display/public/DOCS/JSForm#JSForm-namedFoundSet](http://wiki.servoy.com/display/public/DOCS/JSForm#JSForm-namedFoundSet) :

> Property that tells the form to use a named foundset instead of the default foundset.  
> When “separate” as special value is specified the form will always create a copy of assigned foundset and therefor become separated from other foundsets

and in the property tooltip info in the developer:

> String namedFoundSet Property that tells the form to use a named foundset instead of the default foundset. Currently only “separate” can be specified as value, meaning that the form will use a separate foundset.

I think that the sample is wrong… Can any Servoyan confirm this?

---

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [September 8, 2010, 11:07am UTC](https://forum.servoy.com/t/namedfoundset-in-solutionmodel/12830/5 "2010-09-08T11:07:02Z")

</div>

This is right for a physical form but my forms are designed with the SolutionModel.

If I try formCal1.namedFoundSet = “separate” it returns the same “Stale form” error and if I try separate without quotes it complains that separate is not defined.

I wish it were just so simple.

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [September 8, 2010, 11:46am UTC](https://forum.servoy.com/t/namedfoundset-in-solutionmodel/12830/6 "2010-09-08T11:46:03Z")

</div>

That’s because you call ’ var myFoundSet1 = forms[‘cal1’].foundset;’  
Asking for the foundset of a form simply loads the form in memory.  
After that you’re trying to alter the form again by setting the ‘namedFoundset’ property.

As for the namedFoundset property: as far as I know the solutionModel can not handle any other settings than the normal form properties.

---

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [September 8, 2010, 12:05pm UTC](https://forum.servoy.com/t/namedfoundset-in-solutionmodel/12830/7 "2010-09-08T12:05:43Z")

</div>

Hello Marc,

Thanks for the explanation.

But how can I tell to the form to use a different found set If I have made it with the SolutionModel?  
With the physical Form you just put "separate in the property an the trick is done. But the Solution Model doesn’t allow that.

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [September 8, 2010, 12:37pm UTC](https://forum.servoy.com/t/namedfoundset-in-solutionmodel/12830/8 "2010-09-08T12:37:25Z")

</div>

based on a designtime form I’d say: jsForm.namedFoundSet = ‘separate’ should do the job.  
after that you can load just any foundset you want, without this forms foundset will alter another foundset based on the same table.

---

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [September 8, 2010, 12:45pm UTC](https://forum.servoy.com/t/namedfoundset-in-solutionmodel/12830/9 "2010-09-08T12:45:19Z")

</div>

I wish… as I already wrote:

> If I try formCal1.namedFoundSet = “separate” it returns the same “Stale form” error and if I try separate without quotes it complains that separate is not defined.
> 
> I wish it were just so simple.

Thats why I don’t get it, in the physical forms is so simple… may be a bug?

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [September 8, 2010, 12:56pm UTC](https://forum.servoy.com/t/namedfoundset-in-solutionmodel/12830/10 "2010-09-08T12:56:16Z")

</div>

the “Stale form” error is thrown when you alter a form that’s already in memory.

when you reference ‘forms[‘justAnyFormName’]’ this form is being loaded into memory.  
After that no alterations can be made to that form using the solutionModel as they will result in the “Stale form” error

So: move/delete the line where you reference ‘forms[‘cal1’].foundset’ (Based on your first post I’d say it has no use anymore) and you’re set.

---

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [September 8, 2010, 1:52pm UTC](https://forum.servoy.com/t/namedfoundset-in-solutionmodel/12830/11 "2010-09-08T13:52:10Z")

</div>

Yeah, I forgot that. Now it works

Thank you.
