Hi everybody,
I’m doing a search in my program as detailed here:
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 :|]()
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…
I use Servoy 4.1.3
Here is the code before the error line:
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():
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)
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);
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…
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.
SO here is the line which changes it from True to False:
In SetFilters() the first time it runs the line:
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)
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:
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.
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
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
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
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!
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:
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:
...
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:
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?
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)?
Yes here is exactly what I get:
//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? ![Rolling Eyes :roll:]()
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:
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?
I already made the test to know what is returned by
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 :(]()
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).
Foobrother:
I already made the test to know what is returned by
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.
I have broken down the list causing the problem and have detected the exact bit causing the find to return false:
I did:
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?! ![Rolling Eyes :roll:]()
“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?