2013-12-10 99 views
0

我無法將客戶地址添加到netsuite。除了地址以外,一切都在工作。這是錯誤即時得到回:使用phptoolkit在netsuite中添加客戶地址

警告:試圖將對象分配到類「CustomerAddressbookList」的數組參數「地址簿」,它將被省略

$service = new NetSuiteService(); 

$customer = new Customer(); 
$customerFields = array (
    'firstName'   => "Joe", 
    'lastName'   => "Doe", 
    'companyName'  => "ABC company5", 
    'phone'  => "123456789", 
    'email'    => "[email protected]", 
    'addressbookList' => array (
       'addressbook' => array(
         'addr1'  => "asdfsadf", 
         'city'  => "asfff", 
         'state'  => "asdf", 
         'zip'  => 2323 
       ) 
     ) 
); 
setFields($customer, $customerFields); 

$request = new AddRequest(); 
$request->record = $customer; 

$addResponse = $service->add($request); 

回答

0

我總是試圖先創建記錄,然後再將它們綁在一起。試試類似的東西(未經測試,並且離開我的頭頂):

創建地址簿條目。

$customer = new Customer(); 

    ... 

    $address = new CustomerAddressBook(); 
    $address->defaultShipping = false; 
    $address->defaultBilling = false; 
    $address->attention = "Attention Name"; 
    $address->addr1 = "Address 1"; 
    $address->city = "City"; 
    $address->zip = "12345"; 
    $address->state = "MA"; 

    $addressBook = new CustomerAddressbookList(); 
    $addressBook->addressbook = array($address); 
    $addressBook->replaceAll = false; 


    $customer->addressbookList = $addressBook; 

其餘的代碼對我來說看起來還不錯。

+0

剛剛測試過這段代碼。完美的作品。 –

+0

我收到此錯誤: 由於以下原因之一,您無權設置元素addressbook.attention的值:1)該字段爲只讀; 2)關聯的功能被禁用; 3)當創建或更新記錄時,該字段可用,但在兩種情況下均不可用。 – user2570937

+0

它必須是權限問題。你在使用什麼角色?該字段可以更新,所以不應該成爲問題。相關的功能也不應該是一個問題。 –

相關問題