PHP NetSuite API - 通过internalID范围获取客户记录

时间:2016-09-06 15:44:48

标签: php api netsuite records

我需要将客户从NetSuite同步到另一个系统,并希望通过internalId范围搜索Customers,使用API​​的PHP库。鉴于internalId是自动增量字段,我只需要internalId大于外部系统中最高ID的客户。

有办法做到这一点吗?如果是这样,怎么样?

我目前只能使用SearchRequest和SearchMoreWithIdRequest迭代所有记录。我可以做的一个轻微的优化是以相反的顺序迭代页面以避免过多的重复数据,但如果可能的话,更愿意通过internalId(大于)进行过滤。

由于

这是现有代码

///  initial search

$search = new CustomerSearchBasic();

$request = new SearchRequest();
$request->searchRecord = $search;

$searchResponse = $service->search($request);

// cache the search ID because we're gonna need to re-search, with pagination, using this id
$searchId = $searchResponse->searchResult->searchId;
$totalRecords = $searchResponse->searchResult->totalRecords;

// process the results
process_response($searchResponse);


// get subsequent pages
for ($page = 2; $page < ceil($totalRecords / $pageSize); $page++) {
    echo "[page: $page]  ...   searchId: '$searchId'" . PHP_EOL;
    if (!$searchId) continue;

    $request = new SearchMoreWithIdRequest();
    $request->searchId = $searchId;
    $request->pageIndex = $page;
    $searchResponse = $service->searchMoreWithId($request);

    // process the results
    process_response($searchResponse);
}

function process_response($searchResponse) { ... }

0 个答案:

没有答案