# jsMethod not fired in find mode

**URL:** <https://forum.servoy.com/t/jsmethod-not-fired-in-find-mode/15115>\
**Category:** Classic Servoy\
**Created:** [December 2, 2011, 8:34am UTC](https://forum.servoy.com/t/jsmethod-not-fired-in-find-mode/15115 "2011-12-02T08:34:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [December 2, 2011, 8:34am UTC](https://forum.servoy.com/t/jsmethod-not-fired-in-find-mode/15115/1 "2011-12-02T08:34:50Z")

</div>

Hello,

My onFind method creates a button with a method, but it doesn’t work in find mode.

```auto
	var form = controller.getName()
	var frm = solutionModel.getForm(form)
	var ofgMeth = solutionModel.newGlobalMethod('function totRec(event){var source = event.getElementName();globals.g_search = source}')
        var x = frm.newButton('button',0,0,20,20,ofgMeth)
        x.name = 'button'
	forms[form].controller.recreateUI()
        controller.find()

```

If I remove controller.find() it works.

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [December 2, 2011, 11:19am UTC](https://forum.servoy.com/t/jsmethod-not-fired-in-find-mode/15115/2 "2011-12-02T11:19:16Z")

</div>

did you include something like:

```auto
if(false) controller.search()

```

in your search method?  
Otherwise a method won’t be triggered in find mode.

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [December 2, 2011, 11:33am UTC](https://forum.servoy.com/t/jsmethod-not-fired-in-find-mode/15115/3 "2011-12-02T11:33:05Z")

</div>

In Servoy 6 you don’t need that anymore, there is a JSDoc property to allow method execution in Find mode, it’s called @AllowToRunInFind, check the docs to know more about it.

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [December 2, 2011, 12:57pm UTC](https://forum.servoy.com/t/jsmethod-not-fired-in-find-mode/15115/4 "2011-12-02T12:57:03Z")

</div>

thnkx Nicola!

with all the nice new features in 6, it’s easy to forget some. ![:-)]( "Smile")

---

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [December 2, 2011, 2:06pm UTC](https://forum.servoy.com/t/jsmethod-not-fired-in-find-mode/15115/5 "2011-12-02T14:06:27Z")

</div>

Thank you Nicola,

I will try to find out how it works. I just read the wiki, it’s a bit of a jungle. ![:shock:]( "Shocked")

---

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [December 3, 2011, 10:23am UTC](https://forum.servoy.com/t/jsmethod-not-fired-in-find-mode/15115/6 "2011-12-03T10:23:20Z")

</div>

Ok, @AllowToRunInFind is added, but it still doesn’t work. Could it that it doesn’t apply for the solutionModel?

```auto
/**
 * @AllowToRunInFind
 * 
 * @properties={typeid:24,uuid:"D4C3C1A6-4266-480F-969A-16B7FDCA3E39"}
 * 
 */
function onFind()
{
	controller.find()
	var form = controller.getName()
	var frm = solutionModel.getForm(form)
	var ofgMeth = solutionModel.newGlobalMethod('function totRec(event){var source = event.getElementName();globals.g_search = source}')
        var x = frm.newButton('button',0,0,20,20,ofgMeth)
        x.name = 'button'
	forms[form].controller.recreateUI()

}

```

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [December 4, 2011, 9:50am UTC](https://forum.servoy.com/t/jsmethod-not-fired-in-find-mode/15115/7 "2011-12-04T09:50:55Z")

</div>

Irene, it’s the ‘ofgMeth’ function that should be allowed to run in find mode.

The ‘onFind’ function will run whenever your solution is still in browse mode.
