Friday, July 5, 2019

PHP > 2012.2 Toolkit or later > Find Customer record from phone number

Ability to retrieve all customer records using phone field as filter


<?php


require_once '../PHPToolkit/NetSuiteService.php';


$service = new NetSuiteService();


$service->setSearchPreferences(false, 20);


$phoneNumber = '869';
$phoneSearchField = new SearchStringField();
$phoneSearchField->operator = "startsWith";
$phoneSearchField->searchValue = $phoneNumber;


$search = new CustomerSearchBasic();
$search->phone = $phoneSearchField;


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


?>

No comments:

Post a Comment