Invalid search failure

Almost always the following code works, but I’ve discovered there are some circumstances when it doesn’t. If I manually scroll past the records which match the criteria and then perform the scripted search the code works perfectly.

var s = '#%' + globals.gsearch + '%';

controller.find();
if (globals.gsearchselect == i18n.getI18NMessage('7office.vl.companyname') || globals.gsearchselect == '')
{
	company_name = s;
}
var count = controller.search();

Here’s what sets this code for failure. The current form has less than ALL records loaded. If I add controller.loadAllRecords() at the top of the Find script then the routine works every time. Otherwise, if the form has less than ALL records loaded, it fails every time.

This shouldn’t be. I suspect there may be special circumstances in my current setup causing this.

Servoy 2.2rc4-build322
Java 1.5.0_02-b09 (WindowsXP)
Sybase dbsrv9.0.1.1899

just a question: what if this

globals.gsearchselect == i18n.getI18NMessage('7office.vl.companyname') || globals.gsearchselect == ''

returns false? Then you do

controller.find()
controller.search()

which seems a little odd to me…

patrick:
just a question: what if this

globals.gsearchselect == i18n.getI18NMessage('7office.vl.companyname') || globals.gsearchselect == ''

returns false? Then you do

controller.find()

controller.search()




which seems a little odd to me...

Not so odd. The user is given a popup to select which field they wish to search. If they make no selection then the search defaults to company_name.

Morley:

patrick:
If they make no selection then the search defaults to company_name.

Maybe I am slow today, but I just don’t see where that happens. It has nothing to do with your real problem, but if your if condition fails you don’t do anything useful and if it never fails, you don’t need it. I might oversee something here…

Yes, I think Patrick is right, try this:

var s = '#%' + globals.gsearch + '%';


if (globals.gsearchselect == i18n.getI18NMessage('7office.vl.companyname') || globals.gsearchselect == '')
{
   controller.find();   
   company_name = s;
   var count = controller.search();
}

As noted above, the problem is solved by inserting```
controller.loadAllRecords()


This code was originally established about six months ago, thoroughly tested and was working just fine until early March. I have another situation in which formerly operational code now requires controller.loadAllRecords() before it will work. Not just some instances but univerally, hundreds of situations throughout.

Something peculiar is going on. I posted this issue in the hopes of gaining insights into the underlying cause. Code that works should continue to work indefinitely -- or until the rules are changed.

When new records are created, one should expect the new record will be loaded into the form. When a search is executed it shouldn't matter how many records are currently loaded into the form. 

If there are problems with the above assumptions, please let me know.

This has been a very frustrating past six weeks when a virtually ready-to-deploy solution suddenly exhibits corruption-of-data errors everywhere. 

Kind regards,

This has been a very frustrating past six weeks when a virtually ready-to-deploy solution suddenly exhibits corruption-of-data errors everywhere.

Morley, I know what you mean but you are aware that you are using pre-release software that is subject to errors and changes?

Regarding your problem: I think your code looks strange, as I stated above. You check for a condition but you don’t have an ELSE. So if your condition fails, all you do is find() search(). I don’t know what the outcome should be (I’d expect all records).

If you want help on this, it’d be very useful if you could provide more than

it fails every time.

What exactly fails? What do you want to happen and what happens? We understand from your code above that globals.gsearch contains a user search input, but what is globals.gsearchselect? If you provide more information that allows to understand your problem, I am sure somebody will help.