servoy foundset find() search() bug

Hi Guys,

I am having a problem using servoy find()/search() methods on foundsets. I have a method to find a customer from my customer table by customercode. customer code can a combination of numbers, characters and special characters. I have a customer with customercode: “A\B Something” when I do a search on my customertable foundset I do:

foundset.find();
foundset.customercode = 'A\B Something';
if(foundset.search() > 0){
    application.out('Found customer');
}

This search gives me 0 records and can not find the customer because when I search the customer “A\B Something”, the search function changes the value to “AB Something”. So I escape the "" as the documentation says. That’s how I do it:

foundset.find();
foundset.customercode = 'A\\B Something';
if(foundset.search() > 0){
    application.out('Found customer');
}

This again will give me 0 records although it checks for the right value when I debug it! My customer record is already saved in the database. The foundset is not in the editing mode and I can retrieve the record by using databaseManager.getDataSetByQuery(server_name,sql_query,arguments,max_returned_rows). I was wondering if this is a servoy bug or I am doing something wrong!

I would appreciate it if someone can confirm that they can get search to work with in a similar condition.

Cheers,
Siavash

I actually found a solution to my problem thanks to Lopamudram.

if I modify my code from:

var customerCode = 'A\\B Something';
foundset.find();
foundset.customercode = customerCode;
if(foundset.search() > 0){
    application.out('Found customer');
}

to

var customerCode = 'A\\B Something';
if(customerCode){
	customerCode = utils.stringReplace(customerCode,'\\','\\\\');
}
foundset.find();
foundset.customercode = customerCode;
if(foundset.search() > 0){
    application.out('Found customer');
}

the customercode can be found using servoy foundset find/search methods.

Cheers,
Siavash

Um… How do I go about searching strings that contain characters, like ‘<’, ‘>’, etc?

fs.find();
fs[field_name] = '<mmm';
fs.search();

That doesn’t find my record, it finds all records that are SMALLER than ‘mmm’ :)

So yeah, what’s the solution to this please?

< is smaller. > is greater than

Harjo:
< is smaller. > is greater than

I know :) So there’s no way to find a record that has a value containing the ‘<’ or ‘>’?
Some sort of a generic escape utility, so I don’t have to hardcode a scenario for each particular symbol?

We can Append “\” to the search string to escape the special characters if any. So the result becomes:
fs[field_name] = ‘\<mmm’;
Another approach is to use proper encryption as we use in password fields.

Hope this helps.

Lopamudra
lopamudram@mindfiresolutions.com

lopamudram:
We can Append “\” to the search string to escape the special characters if any. So the result becomes:
fs[field_name] = ‘\<mmm’;
Another approach is to use proper encryption as we use in password fields.

Hope this helps.

Lopamudra
lopamudram@mindfiresolutions.com

Yep, thanks Lopamudra.