Netsuite 使用aftersubmit函数创建用户事件脚本时存在RCRD_DSNT_
我正在尝试编写一个用户事件脚本,加载当前记录,并在提交记录后通过搜索填充行项目值。但是,它给出了一个错误RCRD_DSNT_EXIST,即使记录存在Netsuite 使用aftersubmit函数创建用户事件脚本时存在RCRD_DSNT_,netsuite,suitescript,suitescript2.0,Netsuite,Suitescript,Suitescript2.0,我正在尝试编写一个用户事件脚本,加载当前记录,并在提交记录后通过搜索填充行项目值。但是,它给出了一个错误RCRD_DSNT_EXIST,即使记录存在 function afterSubmit_SO(type){ try { //var record_type = nlapiGetRecordType(); var recordID = nlapiGetRecordId(); var context = nla
function afterSubmit_SO(type){
try
{
//var record_type = nlapiGetRecordType();
var recordID = nlapiGetRecordId();
var context = nlapiGetContext();
var recordOBJ = nlapiLoadRecord('salesorder',recordID);
var source = context.getExecutionContext();
if(source == 'userinterface')
{
var line_count = recordOBJ.getLineItemCount('item');
nlapiLogExecution('DEBUG', 'line count ', line_count);
for(var i = 1; i <= line_count; i++)
{
var itemID = recordOBJ.getLineItemValue('item','item',i);
nlapiLogExecution('DEBUG', 'item ID', itemID);
var filter = new Array();
filter[0] = new nlobjSearchFilter('internalid', null, 'is', itemID);
var columns = new Array();
columns[0] = new nlobjSearchColumn('custitem_web_market_availability');
var a_search_results = nlapiSearchRecord('item',null,filter,columns);
if(a_search_results)
{
for(var x = 0; x < a_search_results.length; x++)
{
var item_web_availability = a_search_results[x].getText('custitem_web_market_availability');
nlapiLogExecution('DEBUG', 'value', item_web_availability);
}
} recordOBJ.setLineItemValue('item','custcol_web_item_availability',i,item_web_availability);
}
var submitID = nlapiSubmitRecord(recordOBJ, true, true);
}
}
catch(exception)
{
nlapiLogExecution('DEBUG','Exception Caught ','' + exception);
}
return true;
}```
提交后的函数(类型){
尝试
{
//var record_type=nlapiGetRecordType();
var recordID=nlapiGetRecordId();
var context=nlapiGetContext();
var recordOBJ=nlapiLoadRecord('salesforder',recordID);
var source=context.getExecutionContext();
如果(源=='userinterface')
{
var line_count=recordOBJ.getLineItemCount('item');
nlapiLogExecution(“调试”、“行计数”、“行计数”);
对于(var i=1;i可能是您的脚本正在执行删除操作。在您提供的代码中,我没有看到对此进行任何检查。如果是删除操作,则提交后用户事件脚本将无法加载删除的记录,这就是为什么会出现错误 afterSubmit函数的
type
参数应该包含操作类型。您可以像if(type=='delete'){return true;}
位于脚本顶部。由于您在nlapiLoadRecord
中对salesorder进行了硬编码,请确保您的脚本仅部署在salesorder上,或者在之前添加return语句。