masterFly
masterFly

Reputation: 1112

Net suite PHP - search for a SalesOrder

I am new to NetSuite. I use 2014 PHP developer kit. I want to search for a SalesOrder (like they have search employees in their sample search.php file).

Lest say, I want to search SO by "salesRep" and get its internalId. After that I want to update "memo".

I tryied to do the search like this,

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

but there I get an Error saying "INVALID_KEY_OR_REF". Then for testing I tries this,

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

Now it is saying "UNEXPECTED_ERROR".

Please help with my code and after I get the search result Please guide me how to update this SalesOrder record.

Thanks in advance.

Upvotes: 1

Views: 1125

Answers (2)

GregC
GregC

Reputation: 271

Just found the answer for this - leaving it here for posterities sake (assuming you are using the older of the 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);

Upvotes: 2

user1944877
user1944877

Reputation: 39

try referring to this sample:

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

Upvotes: 0

Related Questions