使用Postman通过SuiteTalk录入时自定义字段无法赋值问题
问题
在NetSuite中通过SuiteTalk SOAP Web服务创建销售订单记录时,自定义字段custbody_custom_field_1和custbody_custom_field_2始终无法被赋值。已尝试在XML请求中同时使用scriptId和internalId标识字段,但均无效。以下是传入的SOAP请求XML示例:
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header> <applicationInfo xmlns="urn:messages_2019_2.platform.webservices.netsuite.com"> <applicationId>************************************</applicationId> </applicationInfo> <platformMsg:preferences soapenv:mustUnderstand="0" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" xmlns:platformMsg="urn:messages_2019_2.platform.webservices.netsuite.com"> <platformMsg:useConditionalDefaultsOnAdd>true</platformMsg:useConditionalDefaultsOnAdd> <platformMsg:ignoreReadOnlyFields>true</platformMsg:ignoreReadOnlyFields> <platformMsg:warningAsError>false</platformMsg:warningAsError> </platformMsg:preferences> </soapenv:Header> <soapenv:Body> <platformMsg:add xmlns:platformMsg="urn:messages_2019_2.platform.webservices.netsuite.com"> <platformMsg:record xsi:type="ns1:SalesOrder" xmlns:ns1="urn:sales_2019_2.transactions.webservices.netsuite.com" xmlns:ns2="urn:core_2019_2.platform.webservices.netsuite.com" xmlns:ns3="urn:common_2019_2.platform.webservices.netsuite.com"> <ns1:customForm xsi:type="platformCore:RecordRef" internalId="111"/> <ns1:entity xsi:type="platformCore:RecordRef" internalId="222"/> <ns1:tranDate>2024-03-01T00:00:00.000+00:00</ns1:tranDate> <ns1:exchangeRate>1.00</ns1:exchangeRate> <ns1:shippingAddress> <ns3:country>_unitedStates</ns3:country> <ns3:addressee>Johnny Bravo</ns3:addressee> <ns3:addrPhone>800-555-1234</ns3:addrPhone> <ns3:addr1>123 Fake St</ns3:addr1> <ns3:addr2>SUITE 180</ns3:addr2> <ns3:city>Albuquerque</ns3:city> <ns3:state>NM</ns3:state> <ns3:zip>87102</ns3:zip> </ns1:shippingAddress> <ns1:paymentMethod xsi:type="platformCore:RecordRef" internalId="5"/> <ns1:ccNumber>4242424242424242</ns1:ccNumber> <ns1:ccExpireDate>2025-08-01T12:00:00.000+00:00</ns1:ccExpireDate> <ns1:getAuth>T</ns1:getAuth> <ns1:subsidiary xsi:type="platformCore:RecordRef" internalId="1"/> <ns1:itemList> <ns1:item> <ns1:item xsi:type="platformCore:RecordRef" internalId="333"/> <ns1:quantity>1</ns1:quantity> <ns1:description>SERVICE FEE</ns1:description> <ns1:rate>50.00</ns1:rate> <ns1:line>1</ns1:line> </ns1:item> </ns1:itemList> <ns1:customFieldList> <ns2:customField xsi:type="ns2:StringCustomFieldRef" scriptId="custbody_custom_field_1" internalId="444"> <ns2:value>ABCDEF</ns2:value> </ns2:customField> <ns2:customField xsi:type="ns2:StringCustomFieldRef" scriptId="custbody_custom_field_2" internalId="555"> <ns2:value>123456</ns2:value> </ns2:customField> </ns1:customFieldList> </platformMsg:record> </platformMsg:add> </soapenv:Body> </soapenv:Envelope>
排查方向与解决方法
- 修正命名空间归属:SalesOrder的自定义字段应归属到交易命名空间
ns1(urn:sales_2019_2.transactions.webservices.netsuite.com),而非核心命名空间ns2。将<ns2:customField>改为<ns1:customField>,同时调整xsi:type为ns1:StringCustomFieldRef,确保字段与记录类型的命名空间一致。 - 校验字段权限:确认Web服务使用的角色拥有这两个自定义字段的编辑权限,且字段未设置为只读、未限制仅在特定表单下编辑。
- 匹配字段类型:核实自定义字段的实际数据类型,若不是字符串型,需对应使用
LongCustomFieldRef、DateCustomFieldRef等类型,类型不匹配会导致值无法被解析存储。 - 简化字段标识:无需同时传入
scriptId和internalId,保留其中一个即可(优先用scriptId,稳定性更高)。 - 排查用户事件脚本干扰:若启用了
beforeSubmit等用户事件脚本,检查脚本中是否存在覆盖或清空自定义字段值的逻辑,可临时禁用脚本测试赋值是否正常。
内容的提问来源于stack exchange,提问作者Michael McCauley
相关产品推荐
相关产品推荐

