2013-10-31 33 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。这对于你作为一名程序员来说更有意义,并且会让你不断地找出哪个字段包含你正在查找的数据。