我在尝试创建新的入库货件记录时遇到以下错误(Netsuite中的新功能)。
{"type":"error.SuiteScriptError","name":"USER_ERROR","message":"Please enter value(s) for: Item","stack":["anonymous(N/recordService)","<anonymous>(/SuiteScripts/KK_Sandbox_Scripts_SD/RestLets/InboundShipment.js:132)","<anonymous>(/SuiteScripts/KK_Sandbox_Scripts_SD/RestLets/InboundShipment.js:99)","doPost(/SuiteScripts/KK_Sandbox_Scripts_SD/RestLets/InboundShipment.js:34)"],"cause":{"type":"internal error","code":"USER_ERROR","details":"Please enter value(s) for: Item","userEvent":null,"stackTrace":["anonymous(N/recordService)","<anonymous>(/SuiteScripts/KK_Sandbox_Scripts_SD/RestLets/InboundShipment.js:132)","<anonymous>(/SuiteScripts/KK_Sandbox_Scripts_SD/RestLets/InboundShipment.js:99)","doPost(/SuiteScripts/KK_Sandbox_Scripts_SD/RestLets/InboundShipment.js:34)"],"notifyOff":false},"id":"","notifyOff":false}
这是我必须设置记录的代码。我已经验证子列表ID是“items”而fieldId是“itemid”,但是当我尝试添加该行时,我得到了上述错误。
function doPost(restletBody){
log.debug('Called from POST', restletBody);
var success = [],
errors = [];
restletBody.data.forEach(function(e)
{
try
{
log.debug('Called from POST', e.id);
//Create a new record
var rec =
r.create({
type: "inboundshipment",
isDynamic: true,
defaultValues: null
}).setValue({
fieldId: "externalid",
value: e.id,
ignoreFieldChange: false
});
var i = 1;
e.lineitems.items.forEach(function(item)
{
log.debug("Inside Line Items", item.itemid + " " + item.purchaseorder);
rec.selectNewLine({sublistId:"items"});
var field = rec.getSublistFields({
sublistId: 'items'
});
rec.setCurrentSublistValue({
sublistId: "items",
fieldId: "purchaseorder",
value: item.purchaseorder,
ignoreFieldChange: true
});
rec.setCurrentSublistValue({
sublistId: "items",
fieldId: "itemid",
value: item.itemid,
ignoreFieldChange: true
});
log.debug("Inside Line Items", "ITEM Added " + item.itemid );
rec.commitLine({sublistId:"items"});
log.debug("Inside Line Items", "Line Committed" );
++i;
});
rec.save();
}
catch(err)
{
var msg = '';
log.debug("There was an error", err);
}
})
return "";
}
我尝试将itemid更改为shipmentitem和id,但它不起作用。在此之前,我也收到了PO的错误,这是因为名称错了,但我修正了(我相信)该项目。
可能影响它的一件事(不确定)是PO列表过滤项目列表。一旦用户在UI中选择了PO,它就会将项目列表过滤为该PO上的项目。我已经仔细检查过我要提交的项目属于我要提交的PO,但仍然收到错误。有什么想法吗?
答案 0 :(得分:1)
根据NetSuite Record Browser,该字段应为'shipmentitem'。
-
编辑:更新以反映字段名称应为@swwleigh17发现的'shipmentitem',以便将来的用户找到正确的答案。