3 回答
TA贡献1816条经验 获得超6个赞
传递到用户事件中没有currentRecord
属性,因此错误消息告诉您该属性未定义。查看入口点的文档以找到适当的值。context
record
beforeSubmit
TA贡献1806条经验 获得超5个赞
在 SuiteScript 2 上,每个入口点都有不同的参数,因此您需要在帮助中检查这些参数,或者如果您使用 Eclipse 等 IDE,您将在创建新脚本时获得该信息,因此对于 UserEvent 脚本和beforeSubmit入口点,你会得到这样的东西:
/**
* Function definition to be triggered before record is loaded.
*
* Task #5060 : calculate PO Spent Amount and Balance in realtime
*
* @param {Object} scriptContext
* @param {Record} scriptContext.newRecord - New record
* @param {Record} scriptContext.oldRecord - Old record
* @param {string} scriptContext.type - Trigger type
* @Since 2015.2
*/
然后您可以看到 context 参数没有 currentRecord 属性,而是有两个其他参数,您可以使用newRecord或oldRecord,因此您的代码可以如下所示:
/**
*@NApiVersion 2.x
*@NScriptType UserEventScript
*@param {Record} context.currentRecord
*/
define(['N/record'],
function (msg) {
// are you aware that you are "injecting" the 'N/record' library into the 'msg' variable ???
function beforeSubmit(context) {
try {
var record = context.newRecord;
var createdDate = record.getValue({
fieldId: 'createddate'
});
var dataNecessidade = record.getValue({
fieldId: 'custbodyek_data_nece_requ_po'
});
console.log(createdDate ,dataNecessidade);
}
catch(ex){
log.error(ex);
}
}
return {
beforeSubmit : beforeSubmit,
};
});
TA贡献1811条经验 获得超4个赞
你试试这样写,我都是用这个方法来获取字段值。
const bfRecord= context.newRecord;const createdDate = bfRecord.getValue('createddate');
添加回答
举报