2013-10-31 79 views
0

傳遞自定義字段數據我是netSuite的新用戶,嘗試使用web服務將客戶數據傳遞到自定義字段(業務類型,客戶市場,區域),但在xml響應中出現錯誤。net suite如何使用phpToolKit_2013_1

如果有人有什麼想法,請在PHP腳本

幫助以下是腳本和XML響應。

腳本:

 <? 

    require_once '../PHPToolkit/NetSuiteService.php'; 

    $service = new NetSuiteService(); 
    $customer = new Customer(); 
    $customer->lastName = "Amit"; 
    $customer->firstName = "Rathi"; 
    $customer->companyName = "xxxxxxx.xxx"; 
    $customer->phone = "123456789"; 
    $customer->email = "[email protected]"; 


$labName       = new StringCustomFieldRef(); 
$labName->internalId    = "custevent12"; // internal id of the input in Netsuite 
$labName->value   = "USA East"; // your input 

$labName1       = new StringCustomFieldRef(); 
$labName1->internalId    = "custevent11"; // internal id of the input in Netsuite 
$labName1->value   = "Dealer"; // your input 

$labName2       = new StringCustomFieldRef(); 
$labName2->internalId    = "custevent14"; // internal id of the input in Netsuite 
$labName2->value   = "Residential"; // your input 



$customer->customFieldList= new CustomFieldList(); 
$customer->customFieldList->customField = array($labName1,$labName2,$labName); 

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

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

    if (!$addResponse->writeResponse->status->isSuccess) { 
     echo "ADD ERROR"; 
    } else { 
     echo "ADD SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId; 
    } 

    ?> 

XML請求:

<?xml version="1.0" encoding="UTF-8"?> 
    <Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:relationships_2013_1.lists.webservices.netsuite.com" xmlns:ns2="urn:core_2013_1.platform.webservices.netsuite.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="urn:messages_2013_1.platform.webservices.netsuite.com" xmlns:ns4="ns"><Header> 
<passport xsi:type="Passport"><email>[email protected]</email><password>[Content Removed for Security Reasons]</password><account>xxxxx</account><role internalId="3"/></passport></Header> 
<Body><add><record xsi:type="Customer"><firstName>Rathi</firstName><lastName>Amit</lastName><companyName>Live2support.com</companyName><phone>123456789</phone><email>[email protected]</email><customFieldList><customField internalId="custevent11" xsi:type="StringCustomFieldRef"><value>[Content Removed for Security Reasons]</value></customField><customField internalId="custevent14" xsi:type="StringCustomFieldRef"><value>[Content Removed for Security Reasons]</value></customField><customField internalId="custevent12" xsi:type="StringCustomFieldRef"><value>[Content Removed for Security Reasons]</value></customField></customFieldList></record></add></Body></Envelope> 

響應:

 <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header><platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2013_1.platform.webservices.netsuite.com"><platformMsgs:nsId>WEBSERVICES_3434906_10312013233905655255582218_d18e16e7454b3</platformMsgs:nsId></platformMsgs:documentInfo></soapenv:Header><soapenv:Body><addResponse xmlns="urn:messages_2013_1.platform.webservices.netsuite.com"> 
<writeResponse> 
<platformCore:status isSuccess="false" xmlns:platformCore="urn:core_2013_1.platform.webservices.netsuite.com"><platformCore:statusDetail type="ERROR"> 
<platformCore:code>USER_ERROR</platformCore:code> 
<platformCore:message>Please enter value(s) for: Business Type, Customer Market, Regions</platformCore:message> 
</platformCore:statusDetail></platformCore:status></writeResponse></addResponse></soapenv:Body></soapenv:Envelope> 

回答

1

這些自定義字段必須被定義爲強制字段。這裏使用

$customer->customFieldList->customField = array(); 

看樣的幫助https://github.com/TribeHR/NetSuite-PHP-Client/blob/master/samples/add_with_multiple_custom_fields.php

+0

Hi @Saqib, 感謝您的幫助。根據你的回答,我在**上面的問題**中更新了一些更多的代碼。請檢查並建議。 謝謝 – user1376613

+0

@ user1376613變更後你現在得到什麼迴應? – Saqib

+0

' USER_ERROR 請輸入以下值:Business Type,Customer Market,Regions '@ Saqib我已經編輯了上述問題。謝謝 – user1376613

0

您的自定義字段中的內部標識看起來有點嫌疑人提供這些自定義字段中的值。

客戶的自定義字段應該是「custentityXXXXXXX」,其中XXXXXXX是指定給您的字段的名稱。

此外,最好爲自定義字段命名一些有意義的東西。在UI中,在ID字段中,您應該輸入諸如「_business_type」之類的值。 NetSuite會將「custentity」預先設置爲「custentity_business_type」的ID。這對於你作爲一名程序員來說更有意義,並且會讓你不斷地找出哪個字段包含你正在查找的數據。