you can create OR conditions by using foundset.newRecords() between your condition blocks.
Please note also that you should alwasy execute the foundset.find() within an if condition, since the foundset.find() may return false… on your next line you may change the assigned value of your selected record if foundset.find() return false.
You can also concatenate the multiple values using the ||
if (foundset.find()) {
if (vAttributesText1 && vAttributesText2) {
foundset.p_attributes = "#%" + vAttributesText1 + "%||#%" + vAttributesText2 + "%";
}
// ... TODO handle if only 1 text value is set
foundset.search();
}
You can also use the Queri Builder to execute queries on your foundset and search for specific values. To know more about the query builder you can look at this wiki page https://wiki.servoy.com/display/SERV61/Query+builder
Hey,
thanks for your reply but I need an “and” operator and not an “or”.
Yes, I know about the query builder but in this case I have a really large find operation and it would be nice to prevent writing everything new with the query builder.
The default behavior of find mode is AND. The caveat is that you cannot do AND operations on the same dataprovider multiple times.
In your example, you are just re-assigning the next condition, overwriting the first.
Possibly you can us an IN condition here to get the same effect?
foundset.dataprovider = [value1,valueN]
However, that will not use the LIKE operator.
Another approach with the LIKE operator would be to use a pattern wildcard ‘__’
foundset.dataprovider = ‘#%value1__value2%’ // i.e. #%foo__bar% matches ‘FOOBAR’, ‘Food at the bar’, but not ‘foo’ or ‘bar’ by themselves
This ensures that you have a match on both values in a single string (caveat is that they must be in that order, but here, you could use OR in conjunction)
Hi,
yes, I had already thought that. Seems there is no good solution for my requirement because the strings can be in different order. I will rewrite the filter with queryBuilder to get this running.
It is possible to do this with find-search, by using the clearLastResults and reduceSearch parameters of the search function. With clearLastResults=false and reduceSearch=true, you are searching in your previous search results, creating an “and”-search.