Help with passing search options

Hi,

I would like to be able to set the search option via variables ```
controller.search(var1,var2)


My Code below

//********************************************************************
//do clear search first
//********************************************************************

var vOpts1 = arr[0] //sets search options eg controller.search(vOpts1,vOpts2)
var vOpts2 = arr[1]

var vCols = arr[2] //column for first search

forms[vFormName].controller.find()
forms[vFormName][vCols] = "#%"+schField+"%"
forms[vFormName].controller.search(vOpts1,vOpts2);

Hi Phil,

Since the gurus are in Vegas I’ll give it a try.
Setting searchoptions vOpts1 and vOpts2 is possible as long as
they are either “false” or “true”.
But you have to pass the searchvalue to a field not to a variable imho.

Hope this helps,

Ron

Hi Phil and Ron,

Ron:
Since the gurus are in Vegas I’ll give it a try.
Setting searchoptions vOpts1 and vOpts2 is possible as long as
they are either “false” or “true”.

Correct. Those values are optional but when you do pass them you have to pass true or false.

Ron:
But you have to pass the searchvalue to a field not to a variable imho.

You can search on table columns that are not on the form so you don’t necessarily have to search in the form fields.

Also note that going into find mode is not a given. When there is unsaved data (not send to the backend database) the controller.find() will return false and it won’t be in find mode. Any search strings you pass to any column/field will then in fact alter your current record.
So you should always check if you are in findmode like so:

if ( forms[vFormName].controller.find() ) {
	// do your search
} else {
	// not in find mode, tell the user or something
}

To counter most problems you could add databaseManager.saveData() in front of the IF statement. But there is always the risk that data can’t be saved because of field/table constraints of course so always use this IF.

Hope this helps.

Nice tip Robert, thanks.

Ron

prj311:
Hi,

I would like to be able to set the search option via variables ```
controller.search(var1,var2)


My Code below



//********************************************************************
//do clear search first
//********************************************************************

var vOpts1 = arr[0] //sets search options eg controller.search(vOpts1,vOpts2)
var vOpts2 = arr[1]

var vCols = arr[2] //column for first search

forms[vFormName].controller.find()
forms[vFormName][vCols] = "#%"+schField+"%"
forms[vFormName].controller.search(vOpts1,vOpts2);

Thanks Ron/Robert,

So is the syntax correct in my code here ?? ```
forms[vFormName].controller.search**(vOpts1,vOpts2)**;

This should work:

var vOpts1 = “true”
var vOpts2 = “false”

controller.find()
yourformfield = “#%”+searchield+“%”
controller.search(vOpts1,vOpts2)

  1. this should work
  2. preferably use a global searchfield
  3. if this works, then try to get it done with arrays
  4. yourformfield is a FIELD not a variable
  5. you CAN use vars in the last line of code.

Good luck,
Ron