Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > Search API > Methods

Search API: setSearchOption

Scroll Prev Next More

 

Sets the search option for the field. The list of search options is available in the Arguments section. This code should go to AfterTableInit event of the List page.

Syntax

setSearchOption(field, option);

Arguments

field

the name of the field.

option

an option to be set. Accepts one of the following as the search option:

Constants.CONTAINS

Constants.EQUALS

Constants.STARTS_WITH

Constants.MORE_THAN

Constants.LESS_THAN

Constants.BETWEEN

Constants.EMPTY_SEARCH

Constants.NOT_CONTAINS

Constants.NOT_EQUALS

Constants.NOT_STARTS_WITH

Constants.NOT_MORE_THAN

Constants.NOT_LESS_THAN

Constants.NOT_BETWEEN

Constants.NOT_EMPTY

Example 1

How to make sure that the BETWEEN option is always applied when we search for the Year field .

 

Note: this is not an UI option, it will be applied behind the scene. If you need to change the default search option that appears on the Advanced Search page or on the Search panel, proceed to Choose fields -> Search and filter settings and select the default search option for the field in question under 'Options'.

 

 

dynamic srchObj = SearchClause.getSearchObject("Employees");
option = srchObj.getSearchOption("Year");
if (option != BETWEEN) {
srchObj.setSearchOption("Year", Constants.BETWEEN);
}

Example 2

Set the initial search option for Year field to be great than 2019 i.e. find all employees that were hired in 2020 or later

 

dynamic srchObj = SearchClause.getSearchObject("Employees");
srchObj.setFieldValue("2019");
srchObj.setSearchOption("Year", Constants.MORE_THAN);

See also:

Search API: getSearchObject

Search API: getSearchOption()

Choose fields screen: Search and Filter settings

About Search API