0

我是 netSuite 的新手,尝试使用 Web 服务将客户数据传递到自定义字段(业务类型、客户市场、区域),但在 xml 响应中出现错误。

如果有人有想法,请在 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 = "xxxx@xxxxxxx.xxx";


$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>xxxxxx@xxxxx.com</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>xxx@xxxxxx.com</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>
4

2 回答 2

1

这些自定义字段必须定义为必填字段。使用为这些自定义字段提供值

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

请参阅此处的示例以获取帮助https://github.com/TribeHR/NetSuite-PHP-Client/blob/master/samples/add_with_multiple_custom_fields.php

于 2013-10-31T08:12:56.697 回答
0

您的自定义字段的内部 ID 看起来有点可疑。

客户的自定义字段应为“custentityXXXXXXX”,其中 XXXXXXX 是为您的字段指定的名称。

此外,将自定义字段命名为有意义的名称是个好主意。在 UI 的 ID 字段中,您应该输入诸如“_business_type”之类的值。NetSuite 将为此添加“custentity”,ID 为“custentity_business_type”。这对作为程序员的你来说更有意义,并且会让你不必经常弄清楚哪个字段包含你正在寻找的数据。

于 2013-10-31T16:24:20.023 回答