首页 > 解决方案 > NetSuite SuiteTalk SOAP Api:仅更新记录中的某些字段

问题描述

我们在更新 NetSuite 销售订单时遇到了问题(特别是我们正在更新自定义字段),但是我们甚至没有在代码中明确写入一些只读字段。

我们检索订单,更新自定义字段,然后调用WriteResponse rc = this.nsPort.update(order);where orderis an instance of SalesOrderpull byinternalID并且nsPortis an instance of NetSuitePortType。调用update()失败并出现异常:

java.lang.Exception: You do not have permissions to set a value for element subtotal
due to one of the following reasons: 1) The field is read-only; 2) An associated feature
is disabled; 3) The field is available either when a record is created or updated, but 
not in both cases.

哪个字段是只读的在这里并不重要,重要的是我们(无意中)发回涉及只读字段的更新。

令我震惊的是,理想情况下,我们只会发送写入我们感兴趣的自定义字段的更新。

有没有办法从 NetSuite 中提取一条记录,然后只更新某些字段?或者有没有办法在我们调用时通知 SuiteTalk 只更新某些字段update()

标签: javanetsuitesuitetalk

解决方案


如果您只想更新某些字段,只需将您想要更新的字段与internalId. 例如,要仅更新备忘录和销售订单上的自定义字段,请使用(在 python 中):

sales_order = soap.sales.SalesOrder(
    internalId=12,
    memo='I updated the memo, but I did not shoot the deputy',
    customFieldList=soap.core.CustomFieldList(customField=[
        soap.core.CustomString(scriptId='custbody_memo', value='I also did not shoot the deputy'),
    ])
)
soap.update(sales_order)

这将生成一个仅包含自定义正文备注字段internalId的xml。memoNetsuite 只会更新包含在soap 消息中的那些字段。


推荐阅读