我想创建一个 suitescript,它进入销售订单的“salesteam”子列表,并在保存销售订单后将子列表中的第一个值存储到同一销售订单的自定义正文字段中。下面是我的代码。我收到以下错误“SuiteScript 2.x 入口点脚本必须实现一个脚本类型函数。”。感谢任何建议!
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
*/
define(['N/record'],
function afterSubmit(scriptContext){
var currentRec = scriptContext.currentRecord
var salesrep = currentRec.getSublistValue({ //extract sublist value of employee under the Sales Team sublist
sublistId: 'salesteam',
fieldId: 'employee',
line: 1,
});
currentRec.setValue({ //on the current record set value
fieldId:'custbody_salesrep_sublist', //custom body field that will store the sales rep value extracted from the above sublist
value: salesrep,
}); //sets the value of the salesrep into the custom body field
return {
afterSubmit : afterSubmit,
};
}
);
尝试上传脚本并出现错误。期望:我可以将它部署在销售订单上,我创建的自定义正文字段将具有来自 SO 记录上的销售团队子列表的值。