【发布时间】:2016-01-14 18:16:50
【问题描述】:
我正在尝试更新自定义对象中的字段,但是当我这样做时收到错误 java.lang.NullPointerException。
异常的Code对象中也有这个:http://schemas.xmlsoap.org/soap/envelope/:Server.userException。 This S/O thread 表示我发送的请求可能有问题导致服务器抛出异常。但是什么?异常中没有详细信息。
据我所知,我正在关注“SuiteTalk(Web 服务)平台指南”中的更新示例,但这是一个“CustomRecord”而不是“Customer”,所以我必须进行一些更改.
这是我必须帮助更新 CustomRecords 的方法。错误发生在我实际提出请求的最后一行:
private static void UpdateCustomRecordValue(CustomRecord customRecord, string fieldName, string newValue, NetSuiteService netsuiteService)
{
var field = customRecord.customFieldList.Where(custField => custField.scriptId == fieldName).FirstOrDefault();
if (field == null) return;
var updateRecord = new CustomRecord();
updateRecord.scriptId = customRecord.scriptId;
CustomFieldRef[] custFieldList = new CustomFieldRef[] {
new StringCustomFieldRef
{
value = newValue,
scriptId = field.scriptId
}
};
updateRecord.customFieldList = custFieldList;
var updateResponse = netsuiteService.update(updateRecord);
}
【问题讨论】:
-
scriptId 标识记录类型。您还需要记录实例的 internalId。
-
@bknights 谢谢,这让我走上了正确的道路!