Please enable JavaScript to view this site.

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

Search API: setFieldValue

Scroll Prev Next More

 

Replaces an existing value of a search field if the field is already added to the search panel.

 

Adds the field to the search panel if didn't exist there previously.

Syntax

setFieldValue($field, $value);

Arguments

$field

the name of the field.

$value

the value of the search field.

Return value

No return value.

Example

Sets the Department search field to 10 if it is empty. Add the following code to the AfterTableInit event of the List page:

 

$srchObj = SearchClause::getSearchObject("Employees");
 
$value = $srchObj->getFieldValue("Department");
if( $value == null ) {
$srchObj->setFieldValue("Department", 10 );
}

See also:

Search API: getSearchObject

Search API: getFieldValue()

Event: AfterTableInit

About Search API

 

Created with Help+Manual 7 and styled with Premium Pack Version 3 © by EC Software