我有自定义记录类型,但我无法从项目值中搜索条形码:
我正在使用NetSuite PHPToolkit_2015_2和此stackoverflow回答https://stackoverflow.com/a/13366947/2120512和http://burnignorance.com/netsuite-tips-and-hacks/working-with-custom-records-in-suitetalk/来尝试构建此请求:
$service = new NetSuiteService();
// Perform an AdvancedSearch for Items
// https://netsuite.custhelp.com/app/answers/detail/a_id/12203/kw/php%20search%20criteria
$service->setSearchPreferences(false, 1000, false);
$savedSearchId = 'customsearch_barcode_view'; //customsearch## from UI ID field
$searchAdvanced = new CustomRecordSearchAdvanced();
setFields($searchAdvanced, array('savedSearchScriptId'=>$savedSearchId));
$request = new SearchRequest();
$request->searchRecord = $searchAdvanced;
// PHP Toolkit 2012.2: Sample Code to Perform Search that Uses a Custom Field as Filter
// https://netsuite.custhelp.com/app/answers/detail/a_id/25066/kw/php%20custom%20field
$custSearchField = new SearchMultiSelectCustomField();
$custSearchField->value = new ListOrRecordRef();
$custSearchField->value->internalId = "custrecord_barcode_item";
$custSearchField->value->value = "00001 Beer Mug";
$searchAdvanced->customFieldList = $custSearchField;
$results = $service->search($request);
我仍然可以获得自定义记录类型的所有结果,但永远无法弄清楚如何按项目搜索。我做了更改,仍然收到了整个结果。
答案 0 :(得分:0)
我很确定这不会立即解决您的问题,但乍一看我可以在您的代码中看到错误。
customFieldList的类型为array,因此您需要更改它:
$searchAdvanced->customFieldList = $custSearchField;
到此
$searchAdvanced->customFieldList = [$custSearchField];