Below is a sample code on how to perform a search using a custom field as criteria using the PHP Toolkit 2012.2.
Given a custom Free-Form Text Type field with field ID "custentity10"
require_once '../NSPHPClient/NetSuiteService.php';
$service = new NetSuiteService();
$service->setSearchPreferences(false, 20);
$custSearchField = new SearchStringCustomField();
$custSearchField->internalId = "custentity10";
$custSearchField->operator = "startsWith";
$custSearchField->searchValue = "f";
$search = new EmployeeSearchBasic();
$search->customFieldList->customField = $custSearchField;
$request = new SearchRequest();
$request->searchRecord = $search;
$searchResponse = $service->search($request);
if (!$searchResponse->searchResult->status->isSuccess) {
echo "SEARCH ERROR";
} else {
echo "SEARCH SUCCESS, records found: " . $searchResponse->searchResult->totalRecords;
}
No comments:
Post a Comment