# controller.find() results in set property error

**URL:** <https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878>\
**Category:** Classic Servoy\
**Created:** [July 7, 2009, 1:30pm UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878 "2009-07-07T13:30:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Foobrother](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@Foobrother](https://forum.servoy.com/u/Foobrother)\
**Post date:** [July 7, 2009, 1:30pm UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/1 "2009-07-07T13:30:36Z")

</div>

Hi everybody,

I’m doing a search in my program as detailed here:

```auto
if (forms[v_list].controller.find())
		{
			...
			forms[v_list].tbl_assets_to_tbl_assets_users_groups.fld_user_group_id = '^||' + globals.g_current_user_groups;
			...
		}

```

When I run it on Developer it works fine. But when I try it on the server via a client I get this error:

> org.mozilla.javascript.EcmaError: TypeError: Cannot set property “fld\_user\_group\_id” of to “^||1” (InitTree#67)

As if the find() did not work or if a search was lunch before that line. (but I don’t do a search() between the find() and this line) ![:|]( "Neutral")

---

<div class="post-metadata">

**Author:** ![Andrei\_Costescu](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrei\_Costescu](https://forum.servoy.com/u/Andrei_Costescu)\
**Post date:** [July 8, 2009, 12:12pm UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/2 "2009-07-08T12:12:27Z")

</div>

Which version of Servoy are you using?  
Can you make/attach a small sample so we can see the other things you are doing in you JS prior to the line with problems?

I did try something similar to what you describe here but doesn’t reproduce on the version I tested it with…

---

<div class="post-metadata">

**Author:** ![Foobrother](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@Foobrother](https://forum.servoy.com/u/Foobrother)\
**Post date:** [July 8, 2009, 12:26pm UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/3 "2009-07-08T12:26:46Z")

</div>

I use Servoy 4.1.3

Here is the code before the error line:

```auto
if (forms[v_list].controller.find())
		{
			globals.SetFilters(v_form,v_asset_type);
			if (v_asset_type == 1)
			{
				if (v_section=='assets')
				{
					if (forms.frm_navigation_tree_ag.v_tree_selected == 'Open Assets') forms[v_list].fld_inactive = 0;
					application.output('Just Before');
					forms[v_list].tbl_assets_to_tbl_assets_users_groups.fld_user_group_id = '^||' + globals.g_current_user_groups;
				}
				else
				{
					if (forms.frm_navigation_tree_ag.v_tree_selected == 'Open Assets') forms[v_list]['tbl_' + v_section + '_to_tbl_assets'].fld_inactive = 0;
					forms[v_list]['tbl_' + v_section + '_to_tbl_assets'].tbl_assets_to_tbl_assets_users_groups.fld_user_group_id = '^||' + globals.g_current_user_groups;
				}
			}
			try{
				forms[v_list].controller.search();
			}
			catch (e){}

```

Code in globals.SetFilters():

```auto
	var v_filter_form = arguments[0];
	var v_form = arguments[0] + '_list';
	var v_section_name = utils.stringMiddle(v_filter_form,5,-1);
	var v_rf_form = 'frm_' + globals.g_tables[v_section_name] + '_details_layout';
	var v_asset_type = arguments[1];
	var v_type;
	var v_format;
	var v_field_name;
	var v_relation;
	
	forms[v_rf_form].controller.loadAllRecords();
	if (globals.g_sections_filter[v_section_name] != null) {
		if (forms[v_rf_form].controller.find()) {
			var v_start = (globals.g_sections_filter[v_section_name]*1000);
			var v_end = v_start + 999;
			forms[v_rf_form].fld_id = v_start + '...' + v_end;
			forms[v_rf_form].controller.search();
		}
		forms[v_form].fld_section = globals.g_sections_filter[v_section_name];
	}
	for ( var i = 1 ; i < forms[v_rf_form].controller.getMaxRecordIndex()+1 ; i++ )
	{
		forms[v_rf_form].controller.setSelectedIndex(i);
		v_type = forms[v_rf_form].fld_type;
		v_format = forms[v_rf_form].fld_format;
		
		if (v_type <= 100 && v_type !=3 && v_type != 6) //list fields
		{
			v_format = forms[v_rf_form].fld_format;
			if (v_format != 'X')
			{
				v_field_name = forms[v_rf_form].fld_field_name;
				if (forms[v_rf_form].fld_related_field != null)
				{
					v_field_name = forms[v_rf_form].fld_related_field;
				}
				else
				{
					v_field_name = 'fld_' + v_field_name;
				}
// if (v_format == 'check') v_format = null;
				if (v_field_name == 'fld_id') v_format = utils.stringLeft(v_format,2);
				
				v_relation = forms[v_rf_form].fld_relation;
				
				if (v_field_name == 'cal_status' && (v_filter_form == 'frm_changes'||v_filter_form == 'frm_faults'))
				{
					globals.FilterStatus(v_filter_form);
				}
				else
				{
					if (v_relation != null)
					{
						//application.output(v_form + ' : ' + v_relation + '.' + v_field_name + ' : ' + globals.FilterString(forms[v_filter_form]['v_f_' + forms[v_rf_form].fld_field_name],v_format))
						forms[v_form][v_relation][v_field_name] = globals.FilterString(forms[v_filter_form]['v_f_' + forms[v_rf_form].fld_field_name],v_format);
						
					}
					else
					{
						forms[v_form][v_field_name] = globals.FilterString(forms[v_filter_form]['v_f_' + forms[v_rf_form].fld_field_name],v_format);
// application.output(v_form + ' : ' + v_field_name + ' : ' + globals.FilterString(forms[v_filter_form]['v_f_' + forms[v_rf_form].fld_field_name],v_format))
					}
				}
			}
		}
	}
	if (v_asset_type == 1)
	{
		if (v_filter_form == 'frm_assets')
		{
			forms[v_form].fld_id = globals.ChildAssets(globals.g_filter_asset_id);
		}
		else
		{
			forms[v_form].fld_asset_id = globals.ChildAssets(globals.g_filter_asset_id);
		}
	}

```

If I try to run globals.SetFilters() before the find() I get an error because the right part of the following line returns null (“” in the error)

```auto
forms[v_form][v_relation][v_field_name] = globals.FilterString(forms[v_filter_form]['v_f_' + forms[v_rf_form].fld_field_name],v_format);

```

---

<div class="post-metadata">

**Author:** ![Andrei\_Costescu](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrei\_Costescu](https://forum.servoy.com/u/Andrei_Costescu)\
**Post date:** [July 8, 2009, 12:59pm UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/4 "2009-07-08T12:59:09Z")

</div>

Ok ![:)]( "Smile").

It is a bit of code… And I don’t know what tables/relations/tabpanels are there in your solution that may influence the find mode you initially enter. There are also calls to other methods in your solution.

Can you check the status of “forms[v\_list].foundset.isInFind()” before line “forms[v\_list].tbl\_assets\_to\_tbl\_assets\_users\_groups.fld\_user\_group\_id = ‘^||’ + globals.g\_current\_user\_groups;”?  
If it is “false”, please look for the spot in the program flow after “forms[v\_list].controller.find()” where this switches from “true” to “false” and post it.

Even if we find an explanation for why this happens, there is still one thing that puzzles me - why doesn’t it happen in developer? But first things first…

---

<div class="post-metadata">

**Author:** ![Foobrother](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@Foobrother](https://forum.servoy.com/u/Foobrother)\
**Post date:** [July 8, 2009, 1:22pm UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/5 "2009-07-08T13:22:29Z")

</div>

I found an interesting thing which partly explains why it’s working on Developer and not on Server.  
In fact, when I run on developer it goes to the second part of the if (v\_section==‘assets’) and isInFind() is returning True.  
However on server it (in the first part of the if) it returns False.

Now I’ll locate the spot where it goes from true to false and will tell you the line.

---

<div class="post-metadata">

**Author:** ![Foobrother](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@Foobrother](https://forum.servoy.com/u/Foobrother)\
**Post date:** [July 8, 2009, 1:46pm UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/6 "2009-07-08T13:46:32Z")

</div>

SO here is the line which changes it from True to False:  
In SetFilters() the first time it runs the line:

```auto
forms[v_form][v_field_name] = globals.FilterString(forms[v_filter_form]['v_f_' + forms[v_rf_form].fld_field_name],v_format);

```

Then after it’s always at False.

Note that forms[v\_form] in SetFilters() is the same as forms[v\_list] in the main function

**EDIT:** globals.FilterString(forms[v\_filter\_form][‘v\_f\_’ + forms[v\_rf\_form].fld\_field\_name],v\_format) returns null (“” in fact)

---

<div class="post-metadata">

**Author:** ![Andrei\_Costescu](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrei\_Costescu](https://forum.servoy.com/u/Andrei_Costescu)\
**Post date:** [July 8, 2009, 2:11pm UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/7 "2009-07-08T14:11:22Z")

</div>

And inside “globals.FilterString(…)” where does the findmode change from true to false? I am interested in the instruction that does that and does not contain any call to a method written by you.

---

<div class="post-metadata">

**Author:** ![Foobrother](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@Foobrother](https://forum.servoy.com/u/Foobrother)\
**Post date:** [July 8, 2009, 2:21pm UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/8 "2009-07-08T14:21:52Z")

</div>

> Andrei Costescu:  
> And inside “globals.FilterString(…)” where does the findmode change from true to false? I am interested in the instruction that does that and does not contain any call to a method written by you.

Ok I’ll search.

Another interesting thing is that this line in Developer doesn’t change the result to False. It stays True all the time.

---

<div class="post-metadata">

**Author:** ![Foobrother](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@Foobrother](https://forum.servoy.com/u/Foobrother)\
**Post date:** [July 8, 2009, 2:37pm UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/9 "2009-07-08T14:37:20Z")

</div>

Got another issue now.  
I have changed FilterString() to be able to receive another argument but doesn’t seems to work:  
I call it like that

```auto
globals.FilterString(forms[v_filter_form]['v_f_' + forms[v_rf_form].fld_field_name],v_format,v_form);

```

And I take the arguments like that

```auto
function FilterString()
{
	var v_string = arguments[0];
	var v_type = arguments[1];
	var v_form = arguments[2];

```

It says that v\_form is undefined but before sending it, it is not.

Same error on both Developer and Server

---

<div class="post-metadata">

**Author:** ![Foobrother](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@Foobrother](https://forum.servoy.com/u/Foobrother)\
**Post date:** [July 8, 2009, 2:54pm UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/10 "2009-07-08T14:54:10Z")

</div>

I have tried with v\_form in hard: forms[‘string in v\_form’].foundset.isInFind()

I have put the test at the very first line of FilterString() and I get False. Moreover I get False in Developer as well!

---

<div class="post-metadata">

**Author:** ![Andrei\_Costescu](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrei\_Costescu](https://forum.servoy.com/u/Andrei_Costescu)\
**Post date:** [July 8, 2009, 3:27pm UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/11 "2009-07-08T15:27:13Z")

</div>

Hmm… So when you put this debugg message, it changes the behavior in developer as well? Makes it give the error?

It’s something strange there. Are you sure you are not seeing that parameter undefined because it is called from someplace else where you didn’t add the param?  
Are you sure that it is false immediately when it enters FilterString when it is called from where we are interested in and before that exact call the find mode is true?

---

<div class="post-metadata">

**Author:** ![Foobrother](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@Foobrother](https://forum.servoy.com/u/Foobrother)\
**Post date:** [July 8, 2009, 3:40pm UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/12 "2009-07-08T15:40:11Z")

</div>

> Andrei Costescu:  
> Hmm… So when you put this debugg message, it changes the behavior in developer as well? Makes it give the error?
> 
> It’s something strange there. Are you sure you are not seeing that parameter undefined because it is called from someplace else where you didn’t add the param?  
> Are you sure that it is false immediately when it enters FilterString when it is called from where we are interested in and before that exact call the find mode is true?

Here is what I did:  
In SetFilters() I did:

```auto
...

else
					{
						if(forms[v_form].foundset.isInFind())
						{
							application.output('TRUE66');
						}else{
							application.output('FALSE66');
						}
						application.output(v_form); //this displays "frm_assets"
						forms[v_form][v_field_name] = globals.FilterString(forms[v_filter_form]['v_f_' + forms[v_rf_form].fld_field_name],v_format);
						if(forms[v_form].foundset.isInFind())
						{
							application.output('TRUE77');
						}else{
							application.output('FALSE77');
						}
...

```

In FilterString I did:

```auto
function FilterString()
{
	if(forms['frm_assets'].foundset.isInFind())
	{
		application.output('TRUE111');
	}else{
		application.output('FALSE111');
	}
...

```

In Developer I get:  
TRUE66  
FALSE111  
TRUE77

In Server I get:  
TRUE66  
FALSE111  
FALSE77

There is definitely a problem with FilterString because why I can’t send v\_form to it?

---

<div class="post-metadata">

**Author:** ![Andrei\_Costescu](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrei\_Costescu](https://forum.servoy.com/u/Andrei_Costescu)\
**Post date:** [July 9, 2009, 7:24am UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/13 "2009-07-09T07:24:50Z")

</div>

So the output should be something like this for what you described:

TRUE66  
frm\_assets  
FALSE111  
TRUE77

and

TRUE66  
frm\_assets  
FALSE111  
FALSE77

If this is so, I would like to have a look at the solution myself - cause we are doing a kind of debugging through forum right now ![:)]( "Smile"); 111 should be TRUE111 - if possible please create a case in the support system & attach the solution.  
Does the sending of parameters still not work when called from the proper place (where you added extra param)?

---

<div class="post-metadata">

**Author:** ![Foobrother](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@Foobrother](https://forum.servoy.com/u/Foobrother)\
**Post date:** [July 9, 2009, 8:14am UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/14 "2009-07-09T08:14:06Z")

</div>

Yes here is exactly what I get:

```auto
//Developer
TRUE66
frm_assets_list
TRUE111
TRUE77

//Server
TRUE66
frm_assets_list
FALSE111
FALSE77

```

It’s “frm\_assets\_list” and not “frm\_assets” I forgot the “\_list” but I’ve checked again with “frm\_assets\_list” and I get the same results.

However the parameters are now sent successfully! I didn’t change my code but now it works for both. Maybe the reboot of developer changed it ?!

Unfortunately I can’t provide you the whole solution but I can provide the functions involved.  
Are you still interested for that? ![:roll:]( "Rolling Eyes")

---

<div class="post-metadata">

**Author:** ![Andrei\_Costescu](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrei\_Costescu](https://forum.servoy.com/u/Andrei_Costescu)\
**Post date:** [July 9, 2009, 9:06am UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/15 "2009-07-09T09:06:08Z")

</div>

Ok, so now for developer it makes sense - TRUE, TRUE, TRUE. So the question is what happens on the server that makes TRUE turn to false in line:

````auto
forms[v_form][v_field_name] = globals.FilterString(forms[v_filter_form]['v_f_' + forms[v_rf_form].fld_field_name],v_format);
```before the actual call to globals.FilterString(...).

It looks like the simple access to ```
forms[v_filter_form]['v_f_' + forms[v_rf_form].fld_field_name
``` would make that foundset go out of find mode...

Could you replace this line with something like ```
var x = forms[v_filter_form]['v_f_' + forms[v_rf_form].fld_field_name];
``` to make sure this is the culprit?
````

---

<div class="post-metadata">

**Author:** ![Foobrother](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@Foobrother](https://forum.servoy.com/u/Foobrother)\
**Post date:** [July 9, 2009, 9:21am UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/16 "2009-07-09T09:21:50Z")

</div>

I already made the test to know what is returned by

```auto
forms[v_filter_form]['v_f_' + forms[v_rf_form].fld_field_name]

```

it returns because ‘v\_f\_’ + forms[v\_rf\_form].fld\_field\_name doesn’t exist.  
I get the same result on Developer and Sever

The weird think is that it still work on Developer but not on Server. Don’t know why.  
The other problem is that I don’t really know what this non-existing variable represents exactly as it’s not me but my colleague who developed it. And he is on holiday until the 20th ![:(]( "Sad")

---

<div class="post-metadata">

**Author:** ![Andrei\_Costescu](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrei\_Costescu](https://forum.servoy.com/u/Andrei_Costescu)\
**Post date:** [July 9, 2009, 9:28am UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/17 "2009-07-09T09:28:31Z")

</div>

If this is the problem indeed, then it might happen because that code can invoke more of your code in onLoad hooks for example and you do somplace else something to terminate the find mode.  
2 other forms may be loading right then for the first time and trigger those hooks.

And maybe while running in developer these forms are already loaded when you test.  
So you can pin-point the cause much easier by breaking down that line even more and seing what triggers the findmode to terminate.  
If you cannot find any such event handlers/hooks you registered being triggered by that code then it may be a bug and you can add it to the support system without a sample solution for further investigation (but please mention this thread in the case).

---

<div class="post-metadata">

**Author:** ![Andrei\_Costescu](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrei\_Costescu](https://forum.servoy.com/u/Andrei_Costescu)\
**Post date:** [July 9, 2009, 9:30am UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/18 "2009-07-09T09:30:29Z")

</div>

> Foobrother:  
> I already made the test to know what is returned by
> 
> ```auto
> forms[v_filter_form]['v_f_' + forms[v_rf_form].fld_field_name]
> 
> ```
> 
> it returns because ‘v\_f\_’ + forms[v\_rf\_form].fld\_field\_name doesn’t exist.

I meant you should check to see that after you execute this find mode is still true, wasn’t interested in the result.

---

<div class="post-metadata">

**Author:** ![Foobrother](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@Foobrother](https://forum.servoy.com/u/Foobrother)\
**Post date:** [July 13, 2009, 9:46am UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/19 "2009-07-13T09:46:19Z")

</div>

I have broken down the list causing the problem and have detected the exact bit causing the find to return false:  
I did:

```auto
var a = 'v_f_';
//Test1
var b = forms[v_rf_form].fld_field_name;
//Test2
var c = forms[v_filter_form][a+b];
//Test3

```

At Test3 it returns false. Also As I said before, ‘a+b’ doesn’t exist, so c == . Apparently that’s what causing the problem?! Do you think it can be that? Or it’s more likely that it was another “concurrent” bit of code which does that?  
But if it was another bit of code which does that, it would go to false a random moments and not exactly at this instruction each time?! ![:roll:]( "Rolling Eyes")

---

<div class="post-metadata">

**Author:** ![Andrei\_Costescu](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrei\_Costescu](https://forum.servoy.com/u/Andrei_Costescu)\
**Post date:** [July 13, 2009, 11:01am UTC](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878/20 "2009-07-13T11:01:12Z")

</div>

“forms[v\_filter\_form][a+b]” could trigger a load of the form “v\_filter\_form”.  
Have a look at form events attached to this form. Do any of those get executed when this line of code is reached?

[Next page](https://forum.servoy.com/t/controller-find-results-in-set-property-error/10878.md?page=2)
