Netsuite API - PHP将自定义字段附加到新客户

时间:2012-06-05 15:04:09

标签: php soap netsuite

我遇到了netsuite api的问题。我正在尝试添加具有自定义字段类型的客户。 netsuite文档没有任何帮助。我感谢任何帮助。谢谢。

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

}

1 个答案:

答案 0 :(得分:3)

我在我的博客上发布了一个相当深入的代码示例,演示如何add a customer to Netsuite with custom fields in php。它应该至少让你走上正确的道路。