Tuesday, December 18, 2018

PHP Toolkit 2012.2 Sample Code: Use addList to add multiple customers

On the sample PHP toolkit 2012.2 there is a script on how to add customer using add operation.

Below is a sample script on how to add multiple customer record using addList operation.

<?php
require_once '../NSPHPClient/NetSuiteService.php';

$service = new NetSuiteService();

$customer[0] = new Customer();
$customer[0]->lastName = "Doe5";
$customer[0]->firstName = "John5";
$customer[0]->companyName = "ABC company X5 ";
$customer[0]->phone = "123456222";


$customer[1] = new Customer();
$customer[1]->lastName = "Doe6";
$customer[1]->firstName = "John6";
$customer[1]->companyName = "ABC company X6 ";
$customer[1]->phone = "123456333";


$addListRequest = new AddListRequest();
$addListRequest->record = $customer;
$addListResponse = $service->addList($addListRequest);

for($i=0; $i<count($addListResponse->writeResponseList->writeResponse); $i++)
{
    
    if (!$addListResponse->writeResponseList->writeResponse[$i]->status->isSuccess) {
    
        echo "ADD LIST ERROR";
    } else {

        echo "ADD LIST SUCCESS ID" . $addListResponse->writeResponseList->writeResponse[$i]->baseRef->internalId."\n";
        
    }
}
?>

No comments:

Post a Comment