# Trigger method on search

**URL:** <https://forum.servoy.com/t/trigger-method-on-search/1070>\
**Category:** Classic Servoy\
**Created:** [January 21, 2004, 6:25pm UTC](https://forum.servoy.com/t/trigger-method-on-search/1070 "2004-01-21T18:25:46Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![r.rios](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@r.rios](https://forum.servoy.com/u/r.rios)\
**Post date:** [January 21, 2004, 6:25pm UTC](https://forum.servoy.com/t/trigger-method-on-search/1070/1 "2004-01-21T18:25:46Z")

</div>

What I want to do is, after a user performs a find/search operation, display the results on a different form: if foundset == 1 use form A (record view) if foundset \> 1 use form B (list view)

The problem is that controller.find() does not “pause” method execution and I can’t trigger a methond when the user presses Enter key during a find (or can I?)

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [January 21, 2004, 7:17pm UTC](https://forum.servoy.com/t/trigger-method-on-search/1070/2 "2004-01-21T19:17:56Z")

</div>

> r.rios:  
> What I want to do is, after a user performs a find/search operation, display the results on a different form: if foundset == 1 use form A (record view) if foundset \> 1 use form B (list view)
> 
> The problem is that controller.find() does not “pause” method execution and I can’t trigger a methond when the user presses Enter key during a find (or can I?)

You CAN control a find. ![:D]( "Very Happy")

On the script you run in the “onAction” event of your search - you can do exactly what you want:

if(maxRecordIndex == 1) {  
forms.formA.show();  
}  
else {  
forms.formB.show()  
}

Bob Cusick

---

<div class="post-metadata">

**Author:** ![r.rios](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@r.rios](https://forum.servoy.com/u/r.rios)\
**Post date:** [January 21, 2004, 11:43pm UTC](https://forum.servoy.com/t/trigger-method-on-search/1070/3 "2004-01-21T23:43:06Z")

</div>

> bcusick:  
> You CAN control a find. ![:D]( "Very Happy")
> 
> On the script you run in the “onAction” event of your search -
> 
> Bob Cusick

Huh? which “onAction” event are you refering to?

Desired scenario:  
1- user clicks on Select-\>Find  
2- enters find criteria  
3- presses Enter or Select-\>Search  
4- if only 1 record go form A / if \> 1 record go form B

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [January 22, 2004, 1:21am UTC](https://forum.servoy.com/t/trigger-method-on-search/1070/4 "2004-01-22T01:21:09Z")

</div>

> r.rios:  
> Huh? which “onAction” event are you refering to?
> 
> Desired scenario:  
> 1- user clicks on Select-\>Find  
> 2- enters find criteria  
> 3- presses Enter or Select-\>Search  
> 4- if only 1 record go form A / if \> 1 record go form B

Servoy is event driven. If you look at the CRM application that comes with the standard install - you’ll see the custom controller form on the left. There is a single field below each section. You can type anything in there, hit the enter (or return key) and it will perform the find. This is done by use of the “onAction” property of the field.

You can also control when the user goes into find mode via the keyboard equivalent (which is what you’re talking about). Hook up your own method to the “onFindCmd” property of the FORM your user is searching on - and you can control what happens when they choose the FIND command from the menu.

Bob Cusick

---

<div class="post-metadata">

**Author:** ![r.rios](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@r.rios](https://forum.servoy.com/u/r.rios)\
**Post date:** [January 22, 2004, 2:02pm UTC](https://forum.servoy.com/t/trigger-method-on-search/1070/5 "2004-01-22T14:02:32Z")

</div>

Bingo!!!

Thank you very much Bob.

---

<div class="post-metadata">

**Author:** ![Stef](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@Stef](https://forum.servoy.com/u/Stef)\
**Post date:** [March 5, 2004, 10:50am UTC](https://forum.servoy.com/t/trigger-method-on-search/1070/6 "2004-03-05T10:50:42Z")

</div>

OK, we can control when a user ENTERS the find mode.  
But what we need here is to trigger a script “onsearch”.  
Or am I wrong? In Filemaker we can PAUSE a script ans control what happens after “perform find”. I cannot reproduce this in Servoy at the moment. I can solve this by making for each search criteria a global field and use the technique of the CRM, but this is overkill.

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [March 5, 2004, 1:46pm UTC](https://forum.servoy.com/t/trigger-method-on-search/1070/7 "2004-03-05T13:46:24Z")

</div>

We recieved same request also last week, we will add onSearchCmd to a form after final release of Servoy 2.0 (quite a change to allow scripting in findmode)

---

<div class="post-metadata">

**Author:** ![Stef](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@Stef](https://forum.servoy.com/u/Stef)\
**Post date:** [March 5, 2004, 2:23pm UTC](https://forum.servoy.com/t/trigger-method-on-search/1070/8 "2004-03-05T14:23:46Z")

</div>

Great. Would be wonderful.

Thanks Jan!

---

<div class="post-metadata">

**Author:** ![r.rios](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@r.rios](https://forum.servoy.com/u/r.rios)\
**Post date:** [March 5, 2004, 5:09pm UTC](https://forum.servoy.com/t/trigger-method-on-search/1070/9 "2004-03-05T17:09:32Z")

</div>

This is what I’m talking about!!!

---

<div class="post-metadata">

**Author:** ![ellenmeserow](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@ellenmeserow](https://forum.servoy.com/u/ellenmeserow)\
**Post date:** [January 30, 2005, 1:23am UTC](https://forum.servoy.com/t/trigger-method-on-search/1070/10 "2005-01-30T01:23:57Z")

</div>

This feature was discussed as part of 2.0 – any news on it being a part of 2.2? Really need it badly! ![:)]( "Smile")

p.s. In love with Servoy. Really.

ellen

---

<div class="post-metadata">

**Author:** ![pavelzver](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@pavelzver](https://forum.servoy.com/u/pavelzver)\
**Post date:** [February 1, 2005, 11:19pm UTC](https://forum.servoy.com/t/trigger-method-on-search/1070/11 "2005-02-01T23:19:25Z")

</div>

Great feature, can’t wait…to have it.

pavel

---

<div class="post-metadata">

**Author:** ![david](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@david](https://forum.servoy.com/u/david)\
**Post date:** [March 23, 2005, 10:28pm UTC](https://forum.servoy.com/t/trigger-method-on-search/1070/12 "2005-03-23T22:28:26Z")

</div>

bump

---

<div class="post-metadata">

**Author:** ![amisle](https://avatars.discourse-cdn.com/v4/letter/a/a88e57/32.png) [@amisle](https://forum.servoy.com/u/amisle)\
**Post date:** [September 17, 2005, 11:44pm UTC](https://forum.servoy.com/t/trigger-method-on-search/1070/13 "2005-09-17T23:44:03Z")

</div>

(again)

So, when is onSearch going to be added? I could really use it 🙂

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [September 18, 2005, 7:00am UTC](https://forum.servoy.com/t/trigger-method-on-search/1070/14 "2005-09-18T07:00:54Z")

</div>

As far as now, it is there in the latest rc2!

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [September 19, 2005, 8:51am UTC](https://forum.servoy.com/t/trigger-method-on-search/1070/15 "2005-09-19T08:51:05Z")

</div>

It is possible since Servoy 2.2.1 rc1 [http://forum.servoy.com/viewtopic.php?t=4912](http://forum.servoy.com/viewtopic.php?t=4912)  
We expect to release 2.2.1 final within a week
