# Prevent a method from running when on find

**URL:** <https://forum.servoy.com/t/prevent-a-method-from-running-when-on-find/18725>\
**Category:** Classic Servoy\
**Created:** [February 4, 2016, 10:29pm UTC](https://forum.servoy.com/t/prevent-a-method-from-running-when-on-find/18725 "2016-02-04T22:29:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcarlos](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jcarlos](https://forum.servoy.com/u/jcarlos)\
**Post date:** [February 4, 2016, 10:29pm UTC](https://forum.servoy.com/t/prevent-a-method-from-running-when-on-find/18725/1 "2016-02-04T22:29:00Z")

</div>

While using Smart Client:

How can I prevent a method from running when we are on find mode?

Is there something like @AllowToRunInFind, but instead @DoNotAllowToRunInFind?

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [February 5, 2016, 12:49am UTC](https://forum.servoy.com/t/prevent-a-method-from-running-when-on-find/18725/2 "2016-02-05T00:49:24Z")

</div>

Hi Juan-Carlos,

> jcarlos:  
> Is there something like @AllowToRunInFind, but instead @DoNotAllowToRunInFind?

Nope, but you can always add logic in the method to check if you are in find mode using the following code:

```auto
if (!foundset.isInFind()) {
    // we are not in find mode, execute my code
}

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![jcarlos](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jcarlos](https://forum.servoy.com/u/jcarlos)\
**Post date:** [February 5, 2016, 2:48am UTC](https://forum.servoy.com/t/prevent-a-method-from-running-when-on-find/18725/3 "2016-02-05T02:48:47Z")

</div>

Thanks Robert.

I did that and still keep getting the same error:

```auto
Exception Object: com.servoy.j2db.dataprocessing.DataException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 51' at line 1
MSG: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 51' at line 1
is a ServoyException
Errorcode: 100
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 51' at line 1
Wrapped java.lang.RuntimeException: com.servoy.j2db.dataprocessing.DataException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 51' at line 1 (C:\Users\jcarlos\workspace\workspace_serclipse_7_4_4\srms_workspace\FCPAC\forms\frm_tabsMain_gov_proceedings.js#16)
	at C:\Users\jcarlos\workspace\workspace_serclipse_7_4_4\srms_workspace\FCPAC\forms\frm_tabsMain_gov_proceedings.js:16 (setResult_type_of_gov_proceeding)
	at C:\Users\jcarlos\workspace\workspace_serclipse_7_4_4\srms_workspace\FCPAC\forms\frm_tabsMain_gov_proceedings.js:30 (setProceedingTypeValues)
	at C:\Users\jcarlos\workspace\workspace_serclipse_7_4_4\srms_workspace\FCPAC\forms\frm_proceedings_agencies_lst.js:327 (setProceedingType)
	at C:\Users\jcarlos\workspace\workspace_serclipse_7_4_4\srms_workspace\FCPAC\forms\frm_proceedings_agencies_lst.js:308 (setTypesGovProceedingsVLS)
	at C:\Users\jcarlos\workspace\workspace_serclipse_7_4_4\srms_workspace\FCPAC\forms\frm_main_proceedings.js:109 (startFind)
	at C:\Users\jcarlos\workspace\workspace_serclipse_7_4_4\srms_workspace\FCPAC\forms\ui_crud_buttons.js:46 (enterFindModeBaseForm)

```

I added logic on every one of the methods listed about using **if(!foundset.isInFind())**. Actually, I added this condition on every of the methods above except the last two because they are the ones setting the form (and elements) on find mode. I also added that condition on the onRecordSelection and onShow methods.

Still, it’s not working. Weird,

Any other ideas?

Thanks a bunch!  
JC

---

<div class="post-metadata">

**Author:** ![jcarlos](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jcarlos](https://forum.servoy.com/u/jcarlos)\
**Post date:** [February 5, 2016, 2:58am UTC](https://forum.servoy.com/t/prevent-a-method-from-running-when-on-find/18725/4 "2016-02-05T02:58:47Z")

</div>

I found a work around:

```auto
function enterFindModeBaseForm(event)
{
	//scopes.globals.saveRecordInDB();
	var frm = forms[application.getActiveWindow().controller.getName()];
	formElementsInFindModeBaseForm();
	forms.ui_nav_forms_type.onAction_List(event); //to prevent method from running when on find because if (!foundset.isInFind()) is not working
	frm.startFind(event);
	scopes.globals.findMode = 1;
	forms.ui_nav_forms_type.onAction_Form_Edit(); //to set the search form
}

```

Before I run the startFind(event), I go to a simple form (see forms.ui\_nav\_forms\_type.onAction\_List(event)), then I go to the form base for data entry -which are used for search as well.
