John
John

Reputation: 69

Netsuite PHP Toolkit find Sale Order based on tranid

What I'm trying to do seems basic, and should be straight forward, but I'm obviously doing something wrong. I just want to return the Sales Order object based on the tranid. My code is as follows

require_once ('netsuite/PHPToolkit/NetSuiteService.php');
$ns = new NetSuiteService();
$ns->setSearchPreferences(false, 20);
$search = new TransactionSearchBasic();
$needle = new SearchStringField();
$needle->operator = "is";
$needle->searchValue = "SO1047429";
$search->tranid = $needle;
$req = new SearchRequest();
$req->searchRecord = $search;
try {
    $res = $ns->search($req);
} catch (Exception $e) {
    print_r ($e);
    exit;
}
print_r ($res);

Problem is, this is returning every record we have in Netsuite....

SearchResponse Object
(
    [searchResult] => SearchResult Object
        (
            [status] => Status Object
                (
                    [statusDetail] => 
                    [isSuccess] => 1
                )

            [totalRecords] => 3569384
            [pageSize] => 20
            [totalPages] => 178470

I'm hoping that another set of eyes here can spot my error, as it's driving me nuts.

Upvotes: 1

Views: 722

Answers (1)

Tim Rance
Tim Rance

Reputation: 31

You've not specified "tranid" correctly - it needs a capital "I":

$search->tranid = $needle;

should read

$search->tranId = $needle;

Upvotes: 3

Related Questions