我需要搜索特定客户的所有销售订单(使用客户内部ID或实体ID)。当我在脚本下面运行时,它会返回所有销售订单(页面为20)。如何过滤客户的结果?
require_once 'PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();
$service->setSearchPreferences(false, 20);
$SearchEnumMultiSelectField = new SearchEnumMultiSelectField();
$SearchEnumMultiSelectField->searchValue = Array('_salesOrder');
$SearchEnumMultiSelectField->operator = 'anyOf';
$search = new TransactionSearchBasic();
$search->type = $SearchEnumMultiSelectField;
//$search->customForm = new SearchMultiSelectField();
//$id = new RecordRef();
//$id->internalId = 'xxxxxx'; customer internal Id
//$search->customForm->searchValue = $id;
$request = new SearchRequest();
$request->searchRecord = $search;
$searchResponse = $service->search($request);
echo print_r($searchResponse,true);
答案 0 :(得分:0)
$service = new NetSuiteService(self::_config);
$customerSearchBasic = new CustomerSearchBasic();
$searchValue = new RecordRef();
$searchValue->type = 'customer';
$searchValue->internalId = $customer_id;
$searchMultiSelectField = new SearchMultiSelectField();
setFields($searchMultiSelectField, array('operator' => 'anyOf', 'searchValue' => $searchValue));
$customerSearchBasic->internalId = $searchMultiSelectField;
$transactionSearchBasic = new TransactionSearchBasic();
$searchMultiSelectEnumField = new SearchEnumMultiSelectField();
setFields($searchMultiSelectEnumField, array('operator' => 'anyOf', 'searchValue' => "_salesOrder"));
$transactionSearchBasic->type = $searchMultiSelectEnumField;
$transactionSearch = new TransactionSearch();
$transactionSearch->basic = $transactionSearchBasic;
$transactionSearch->customerJoin = $customerSearchBasic;
$request = new SearchRequest();
$request->searchRecord = $transactionSearch;
$searchResponse = $service->search($request);
if ($searchResponse->searchResult->status->isSuccess) {
if(isset($searchResponse->searchResult->recordList)) {
return $searchResponse->searchResult->recordList->record;
}
}