Netsuite PHP - 搜索销售订单

时间:2015-03-19 07:41:29

标签: php netsuite

我是NetSuite的新手。我使用2014 PHP开发人员工具包。我想搜索SalesOrder(就像他们的样本search.php文件中有搜索员工一样)。

免得说,我想通过" salesRep"并获得其internalId。之后我想更新"备忘录"。

我试图像这样进行搜索,

$gr = new GetRequest();
$gr->baseRef = new RecordRef();
$gr->baseRef->salesRep= "<name>";
$gr->baseRef->type = "salesOrder";

但是我收到错误说&#34; INVALID_KEY_OR_REF&#34;。然后进行测试我试试这个,

$gr = new GetRequest();
$gr->baseRef = new RecordRef();
$gr->baseRef->internalId = 387555;
$gr->baseRef->type = "salesOrder";

现在它说'#34; UNEXPECTED_ERROR&#34;。

请帮助我的代码并在获得搜索结果后请指导我如何更新此SalesOrder记录。

提前致谢。

2 个答案:

答案 0 :(得分:1)

刚刚找到答案 - 为了后人的缘故留下它(假设您使用的是旧版的PHPToolKits)

$service = new NetSuiteService();
$search = new TransactionSearchBasic();
$searchStringField = array('searchValue' => "SO1267816",
                       'operator' => 'is');
$search->tranId=$searchStringField;
$request = new SearchRequest();
$request->searchRecord = $search;
$searchResponse = $service->search($request);

echo print_r($searchResponse,true);

答案 1 :(得分:0)

尝试参考此示例:

$service = new NetSuiteService();

$service->setSearchPreferences(false, 20);

$emailSearchField = new SearchStringField();
$emailSearchField->operator = "startsWith";
$emailSearchField->searchValue = "j";

$search = new EmployeeSearchBasic();
$search->email = $emailSearchField;

$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;
}