Hot to execute a "Find"

Questions, tips and tricks and techniques for scripting in Servoy

Hot to execute a "Find"

Postby cema » Thu May 08, 2003 4:08 pm

When I want to select records interactively on a form I do:

1) Click "Select" ---> "Find" (Servoy enters the "find" mode)
2) Write the search criteria in some of the fields of the form
3) Click "Select" ---> "Search" (Servoy selects the data that match the criteria).

How can I do this in a method?
I can do it in a FileMaker script but I cannot imagine a way to do in a Servoy method.

Thank you.
Ranieri Piazza
cema
 
Posts: 8
Joined: Wed Apr 30, 2003 12:49 pm
Location: Milano (Italy)

Postby maarten » Thu May 08, 2003 8:49 pm

Hi Ranieri,

This is indeed a bit tricky.

In a normal form this won't work, because in find mode , buttons are disabled and you cannot "pause' a script like in Filemaker. However you can use a controllerForm attached to the form you want to perform your search on, because a controllerForm stays in browse mode.

Here's a "workaround":

Let's assume you have a controller form called "navigator"
and a main form called "companies"

1) create 2 buttons in the form "navigator"
2) make sure they both have the property called "name" entered with let's say "search1" and "search2"
3) create 2 scripts on the form "navigator"

script1 (attached to button named "search1")
currentcontroller.find() // sets form "companies" to find mode
elements.search1.visible=false //hides search1 button
elements.search2.visible=true // shows search2 button


script2 (attached to button named "search2")
currentcontroller.search() // executes the search on "companies" form
elements.search1.visible=true //shows search1 button again
elements.search2.visible=false // hides search2 button


make sure button1 sits on top of button2

Notes:
Use the "text" property to define the button text (this is displayed in browse mode)
Use the "name" property to define the button name(this is displayed in
the Method editor. (elements tree)
This script will work on ALL forms that have "navigator" as controller.

Hope this helps you out.
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby cema » Fri May 09, 2003 9:43 am

Thanks - I will try as soon as possible.
Ranieri Piazza
cema
 
Posts: 8
Joined: Wed Apr 30, 2003 12:49 pm
Location: Milano (Italy)

Postby cema » Fri May 09, 2003 2:33 pm

Hi Maarten,

I understood your "workaround" and I tried it, but it doesn't work. :?

I left the two buttons graphically separated (not overlapped) just to see exactly what happens.

Script1 works: when you click the button Servoy enters the "find" state (you can see the word "find" in the lower left corner of the window) and you can write the search criteria in the fields of the "controlled" form.

But when you click button2 (Script2) nothing happens.
Servoy remains in the "find" state and the only way I found to go on is to click on the upper menu on the comman "Select --> Search" (this way the search is exactly accomplished with the criteria entered).

The fact is that while in "find" mode you can click on the button but the method is not activated.
If you enable the "method debugger" you can see that the method does not start at all.

I think I've correctly set up all the pieces because if Servoy is in "ready" mode then Script2 is activated when I click the botton.

Any idea? :idea:
Ranieri Piazza
cema
 
Posts: 8
Joined: Wed Apr 30, 2003 12:49 pm
Location: Milano (Italy)

Postby maarten » Fri May 09, 2003 4:38 pm

Hi Ranieri,

I forgot to mention one important thing which is probably causing your problem.
Make sure the navigation controller has a different table then your main form has! Otherwise it will be "dragged" into the find mode as well.

I realised that in the crm demo, the navigation form also doesn't have it's own table. (it's using the companies table). Bad example :(
In the next build, navigation controller will link to it's own table MAIN.

Sorry for this inconvenience.
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby cema » Mon May 12, 2003 11:08 am

Hi Maarten,

It works.
I actually attached the navigator to the same table.
Now I have created a "dummy" form to be used by the navigator and all is OK.

I need another tip.

In FileMaker I can check the "omit" box in Find mode.
In Servoy is it correct to do a "controller.search" followed by a "controller.invertRecors" ?

What is the purpose of "controller.omitRecord" and "controller.loadOmittedRecords" ?

Where can I find the corresponding list (FileMaker vs. Servoy) of the "symbols" I can use in a Find (I mean < > * ... == and so on)?

Thanks.
Ranieri Piazza
cema
 
Posts: 8
Joined: Wed Apr 30, 2003 12:49 pm
Location: Milano (Italy)

Postby maarten » Mon May 12, 2003 11:30 pm

Hi Maarten,

It works.
I actually attached the navigator to the same table.
Now I have created a "dummy" form to be used by the navigator and all is OK.

I need another tip.

In FileMaker I can check the "omit" box in Find mode.
In Servoy is it correct to do a "controller.search" followed by a "controller.invertRecors" ?
you can use e.g "!Boston" in your find request(leaves out all records with Boston)
Invert toggles between foundset and rest of all records in table
What is the purpose of "controller.omitRecord" and "controller.loadOmittedRecords" ?
Omit sets record apart in the omit set so to speak.
It doesn't add it to the rest of all records outside the found set like FMP does.
So if you omit 2 records in a foundset, you will also get back 2 records by doing loadOmittedRecords.
If you do invert, you'll get back all records in table minus foundset.
Invert again , and you'll get back found set again


Where can I find the corresponding list (FileMaker vs. Servoy) of the "symbols" I can use in a Find (I mean < > * ... == and so on)?
Check out the "Finding Data" under the "Getting Started" section in the manual. http://developer.servoy.com/docs/developer/index.htm


Thanks.
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby cema » Wed May 14, 2003 6:04 pm

Thank you for your information. In the previous release of the Servoy manual there was not the paragraph about "finding data".

One more question.
I think I understood the meaning of the "invert record" command but I'm not able to let it work :?

I open a form, choose from the menu "select - find", enter search criteria, choose "select - search" and obtain the correct "foundset" :)

Now I do "select - invertrecords" and I expect to obtain the complementary set (i.e. all the records except those founded before) but instead I obtain a "no result" :(

This in my trial database.
I've also tested your "crm" database but it's the same.

What's wrong?
Ranieri Piazza
cema
 
Posts: 8
Joined: Wed Apr 30, 2003 12:49 pm
Location: Milano (Italy)

Postby maarten » Thu May 15, 2003 9:03 am

Hi Ranieri,

This is a bug. Will be fixed asap.
Thanks for pointing out.
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby maarten » Fri May 16, 2003 9:18 am

maarten wrote:Hi Ranieri,

This is a bug. Will be fixed asap.
Thanks for pointing out.


Fixed. Will be in next build.
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby cema » Fri May 16, 2003 9:27 am

OK - Waiting for next release.
Ranieri Piazza
cema
 
Posts: 8
Joined: Wed Apr 30, 2003 12:49 pm
Location: Milano (Italy)


Return to Methods

Who is online

Users browsing this forum: No registered users and 10 guests