controller.find() results in set property error

Questions, tips and tricks and techniques for scripting in Servoy

controller.find() results in set property error

Postby Foobrother » Tue Jul 07, 2009 3:30 pm

Hi everybody,

I'm doing a search in my program as detailed here:
Code: Select all
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) :|
Current configuration: Servoy 5.2.6 Build 1011, Java 6u24, PostgreSQL 8.3, Windows Server 2003

Servoy / Java Developer
http://www.assetguardian.com
User avatar
Foobrother
 
Posts: 530
Joined: Tue Jan 13, 2009 5:46 pm

Re: controller.find() results in set property error

Postby Andrei Costescu » Wed Jul 08, 2009 2:12 pm

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...
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: controller.find() results in set property error

Postby Foobrother » Wed Jul 08, 2009 2:26 pm

I use Servoy 4.1.3

Here is the code before the error line:
Code: Select all
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():
Code: Select all
   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)
Code: Select all
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);
Current configuration: Servoy 5.2.6 Build 1011, Java 6u24, PostgreSQL 8.3, Windows Server 2003

Servoy / Java Developer
http://www.assetguardian.com
User avatar
Foobrother
 
Posts: 530
Joined: Tue Jan 13, 2009 5:46 pm

Re: controller.find() results in set property error

Postby Andrei Costescu » Wed Jul 08, 2009 2:59 pm

Ok :).

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...
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: controller.find() results in set property error

Postby Foobrother » Wed Jul 08, 2009 3:22 pm

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.
Current configuration: Servoy 5.2.6 Build 1011, Java 6u24, PostgreSQL 8.3, Windows Server 2003

Servoy / Java Developer
http://www.assetguardian.com
User avatar
Foobrother
 
Posts: 530
Joined: Tue Jan 13, 2009 5:46 pm

Re: controller.find() results in set property error

Postby Foobrother » Wed Jul 08, 2009 3:46 pm

SO here is the line which changes it from True to False:
In SetFilters() the first time it runs the line:
Code: Select all
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)
Current configuration: Servoy 5.2.6 Build 1011, Java 6u24, PostgreSQL 8.3, Windows Server 2003

Servoy / Java Developer
http://www.assetguardian.com
User avatar
Foobrother
 
Posts: 530
Joined: Tue Jan 13, 2009 5:46 pm

Re: controller.find() results in set property error

Postby Andrei Costescu » Wed Jul 08, 2009 4:11 pm

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.
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: controller.find() results in set property error

Postby Foobrother » Wed Jul 08, 2009 4:21 pm

Andrei Costescu wrote: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.
Current configuration: Servoy 5.2.6 Build 1011, Java 6u24, PostgreSQL 8.3, Windows Server 2003

Servoy / Java Developer
http://www.assetguardian.com
User avatar
Foobrother
 
Posts: 530
Joined: Tue Jan 13, 2009 5:46 pm

Re: controller.find() results in set property error

Postby Foobrother » Wed Jul 08, 2009 4:37 pm

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
Code: Select all
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
Code: Select all
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
Current configuration: Servoy 5.2.6 Build 1011, Java 6u24, PostgreSQL 8.3, Windows Server 2003

Servoy / Java Developer
http://www.assetguardian.com
User avatar
Foobrother
 
Posts: 530
Joined: Tue Jan 13, 2009 5:46 pm

Re: controller.find() results in set property error

Postby Foobrother » Wed Jul 08, 2009 4:54 pm

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!
Current configuration: Servoy 5.2.6 Build 1011, Java 6u24, PostgreSQL 8.3, Windows Server 2003

Servoy / Java Developer
http://www.assetguardian.com
User avatar
Foobrother
 
Posts: 530
Joined: Tue Jan 13, 2009 5:46 pm

Re: controller.find() results in set property error

Postby Andrei Costescu » Wed Jul 08, 2009 5:27 pm

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?
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: controller.find() results in set property error

Postby Foobrother » Wed Jul 08, 2009 5:40 pm

Andrei Costescu wrote: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:
Code: Select all
...

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:
Code: Select all
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?
Current configuration: Servoy 5.2.6 Build 1011, Java 6u24, PostgreSQL 8.3, Windows Server 2003

Servoy / Java Developer
http://www.assetguardian.com
User avatar
Foobrother
 
Posts: 530
Joined: Tue Jan 13, 2009 5:46 pm

Re: controller.find() results in set property error

Postby Andrei Costescu » Thu Jul 09, 2009 9:24 am

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 :); 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)?
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: controller.find() results in set property error

Postby Foobrother » Thu Jul 09, 2009 10:14 am

Yes here is exactly what I get:
Code: Select all
//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:
Current configuration: Servoy 5.2.6 Build 1011, Java 6u24, PostgreSQL 8.3, Windows Server 2003

Servoy / Java Developer
http://www.assetguardian.com
User avatar
Foobrother
 
Posts: 530
Joined: Tue Jan 13, 2009 5:46 pm

Re: controller.find() results in set property error

Postby Andrei Costescu » Thu Jul 09, 2009 11:06 am

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:
Code: Select all
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
Code: Select all
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
Code: Select all
var x = forms[v_filter_form]['v_f_' + forms[v_rf_form].fld_field_name];
to make sure this is the culprit?
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Next

Return to Methods

Who is online

Users browsing this forum: No registered users and 36 guests