I'm using NetSuite PHP Toolkit - the slightly modified version by Travis G. Hansen https://github.com/travisghansen/netsuite-php-toolkit.
I can connect and I'm getting the right results. But even if I switch the setSearchPreferences
method to true (3rd parameter) I still get all the columns for the transaction type. I want only see to the ones specified in the saved search. Switching the parameter only shows/hides value of the fields, but I'm still left with hundreds of empty, unwanted columns. That includes items columns if I also have item join used in the saved search.
Am I doing something wrong here or is this just the way it works? I've already learned that I can't use calculated columns, but if I must download hundreds of empty columns then I don't see much point of using saved searches with SOAP. The only advantage being that you can predefine criteria.
Here's the code.
use NetSuite\Classes\SearchStringField;
use NetSuite\Classes\SearchRequest;
use NetSuite\Classes\TransactionSearchAdvanced;
use NetSuite\Classes\SearchMoreWithIdRequest;
$service->logRequests(true);
$service->setSearchPreferences(true, 1000, true);
$search = new TransactionSearchAdvanced();
$search->savedSearchId = '999999'; // Your SavedSearch ID.
$request = new SearchRequest();
$request->searchRecord = $search;
$searchResponse = $service->search($request);
The predefined criteria are it. Your only filters are body fields only or all body and sublist values.
If you are thinking that limiting the fields will increase performance you'd be mistaken.