Question

I am having the trouble with the netsuite api. I am trying to add a customer with a custom field type. The netsuite documentation are of no help. I appreciate any help i could get. Thank You.

$customFields = array('internalId' => 'custentity_nso_f_donortype', 
                      'value' => new nsListOrRecordRef(array('internalId' => "1"))
                );
$customObject = new nsComplexObject("SelectCustomFieldRef");
$customObject->setFields($customFields);
$customerFields = array (
        'isPerson'          => true,
        'firstName'         => $firstName,
        'lastName'          => $lastName,
        'companyName'           => $companyName,
        'phone'             => $phone,
        'email'             => $email,
        'customFieldList'   => $customObject,
        'addressbookList'   => array (
                'addressbook'   => array(
                        'addr1'     => $addr1,
                        'city'      => $city,
                        'state'     => $state,
                        'zip'       => $zip
                )
        )
);

// create Customer record
$customer = new nsComplexObject('Customer');
// set fields
$customer->setFields($customerFields);

// perform add operation and store nsWriteResponse object in $addResponse variable
$addResponse = $myNSclient->add($customer);

// handle add response
if (!$addResponse->isSuccess) {

    echo "<font color='red'><b>" . $addResponse->statusDetail[0]->message . "</b></font>";

} else {

    echo "<font color='green'><b>SUCCESS!!!</b></font>";

}
Was it helpful?

Solution

I have posted a fairly in-depth code example on my blog that demonstrates how to add a customer to Netsuite with custom fields in php. It should at least start you on the right path.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top