I need to run a criteria in Find / Search such as:
!2 && !3
Not = 2 AND Not = 3
There does not appear to be an operator to do this in the Find/Search criteria in Servoy. How is this accomplished?
I need to run a criteria in Find / Search such as:
!2 && !3
Not = 2 AND Not = 3
There does not appear to be an operator to do this in the Find/Search criteria in Servoy. How is this accomplished?
!2 && !3 is the same as !(2 || 3). So try !2||3 (never tried it, but perhaps this will work, because perhaps the NOT operator works on the whole expression)
Otherwise:
foundset.find()
foundset.field = '!2'
foundset.search(true, false)
foundset.find()
foundset.field = '!3'
foundset.search(false, true)
martinh:
!2 && !3 is the same as !(2 || 3). So try !2||3 (never tried it, but perhaps this will work, because perhaps the NOT operator works on the whole expression)Otherwise:
foundset.find()
foundset.field = ‘!2’
foundset.search(true, false)
foundset.find()
foundset.field = ‘!3’
foundset.search(false, true)
Hi Martin - looks like it should work but does not. Only the 2 is negated with !2||3. My actual criteria is more complex but without an AND operator its impossible to do the negation. Working around it with multiple OR criteria at the moment such as 1||3…5||7…9||>=11 which in this instance does return the correct data but !2&&!6&&!10 is a lot more sensible fro the user to apply.
Unfortunately I need to just put this form in find and search and the columns take care of themselves - so I don’t interact with each search. We use a base form and one button puts the form in find mode then another runs search.
Kahuna:
My actual criteria is more complex but without an AND operator its impossible to do the negation.
If your query is that complex, why not using a loadRecords() with a query as argument?
martinh:
If your query is that complex, why not using a loadRecords() with a query as argument?
As I mentioned Martin we just allow the user to do a Find/Search on the fly so we are not interacting with any of the fields on the form (actually just use a base form to set it into find then search). When I say complex its simply more criteria and in ranges and with (negation) where required. There are lots of fields on this form and we choose to use the simple built in operators - or at least we’d like to if they were complete with an AND operator. Looks like it would only be useful in the negation search of course.
Then the only thing you can do is the following:
// User input
input = '!2&&!6&&!10'
// Make it an array
array = input.split("&&")
for (var i = 0; i < array.length; i++)
{
foundset.find()
foundset.field = array[i]
if (i == 0)
foundset.search(true, false)
else
foundset.search(false, true)
}
and what about:
foundset.find()
foundset.field = '!2'
controller.newRecord()
foundset.field = '!3'
foundset.search()
I’m not sure if I am missing a point here Martin and Harjo.
The only code I’m running is to set the form into find: foundset.find
Then into search: foundset.search
The user enters criteria into any of the fields on the form based on the list of operators supplied by Servoy, and Servoy takes care of selecting the correct records.
I’m not running any code on any specific form fields so doing: foundset.field = ‘!2’
or similar is not an option. I was hoping there was an operator that Servoy had not documented that would allow a multiple negation such as !2&&!6 etc. Unfortunately only the first criteria is recognised in this event.
At the moment re-writing the form search code is not an option, thanks for all of the input Guys - we will be deplying a full filtering form soon and will keep all of your suggestions in mind.
Mean tine - Servoy any comments on the && Operator?
you can create a button, that does: controller.newRecord() or use CTRL-N or (apple) CMD-N
Hi Folks
Revisiting this challenge as it has become critical now to our Filter Tool deployment.
Here is the scenario.
We have several forms in a tab, on show they all go into find mode and the user can enter criteria. When the button to search is clicked the SQL that is developed by the search is then used as a limiter (foundset filters) for the various tables represented in the tabs.
The find criteria is saved in an array and the user can then go back and select the saved find at any time. When he selects it from the list of previous finds the fields in the form are repopulated. In this way the user can always see the criteria he has used.
The challenge is still that we cannot use a logical AND in an field. For example !2 and !5 (or in Servoy !2&&!5). The and is not available. Previous posters have suggested several work around’s, however in this design instance none of them are actually feasible.
We can’t put the forms back into find again since (even if that worked) the user would not see all of his criteria at the time nor be able to use all the entered criteria when restored form a saved array.
We can’t always use extended or’s either since some of the data is text (!NONE&&!Yes) - and to be honest this is where the real difficulty is (in text fields) since thee is no work around using or in large text tables.
Entering the extra data from code has the same effect.
I guess there are two questions:
Why is there no Logical AND in the Servoy find on form? and
Is there a way to work around this where the criteria is shown in the field on the find form - especially where the data is textual?
Servoy Guru’s - suggestions welcome and most appreciated!
I didn’t understand one thing, which one of the following is the scenario:
In scenario 1 you could apply a foundset filter before performing the real search, in scenario 2 IMHO you should just teach your users to use a step by step approach: perform the main search and use a second search to reduce the foundset or simply teach them how to use multiple search criterias at once as Harjo suggested.