Search code examples
phpnetsuitesuitescript2.0php-toolkit

Netsuite Phptoolkit Could not determine customer compid


Trying to get the customer information using phptoolkit Here's my code:

function getCustomer(){
  $service = new NetSuiteService();

  $request = new GetRequest();
  $request->baseRef = new RecordRef();
  $request->baseRef->account_id = "252206";
  $request->baseRef->type = "customer";
  $getResponse = $service->get($request);

  if (!$getResponse->readResponse->status->isSuccess) {
     echo "GET ERROR";
  } else {
     $customer = $getResponse->readResponse->record;
     echo "GET SUCCESS, customer:";
     echo "\nCompany name: ". $customer->companyName;
     echo "\nInternal Id: ". $customer->internalId;
     echo "\nEmail: ". $customer->email;
  }
}

And getting error like this.

Fatal error: Uncaught SoapFault exception: [soapenv:Server.userException] Could not determine customer compid in phptoolkit/NSPHPClient.php:338 Stack trace: #0 phptoolkit/NSPHPClient.php(338): SoapClient->__soapCall('get', Array, NULL, Array) #1 phptoolkit/NetSuiteService.php(145953): NSPHPClient->makeSoapCall('get', Object(GetRequest)) #2 netsuite.php(23): NetSuiteService->get(Object(GetRequest)) #3


Solution

  • Base on the netsuite documentation RecordRef only accept internalId and type

    $request->baseRef = new RecordRef();
    $request->baseRef->internalId = "252206";
    $request->baseRef->type = "customer";