我试图在用户打开采购订单时对其进行修改。这似乎是一个非常简单的示例,但似乎不起作用。在GUI中,我看不到“测试”备注。并且在脚本调试中,备注字段为空。
由于调试,我知道脚本正在运行。
/**
* Update Drop Ship PO with route Information
*
* @author Patrick
* @NApiVersion 2.0
* @NScriptType UserEventScript
*/
define(['N/search', 'N/record'],
function(search, record) {
function beforeLoad(context) {
var newRecord = context.newRecord;
newRecord.setValue({fieldId: 'memo', value: 'this is a test'});
log.debug({title: 'memo', details: newRecord.getValue({fieldId: 'memo'})});
return true;
}
return {
beforeLoad: beforeLoad
};
});
我假设它与我可以修改的记录有关,但是我一生无法在文档中找到一个可行的示例。任何帮助将不胜感激。
答案 0 :(得分:3)
您无法修改beforeLoad
中现有记录上的字段;有关详细信息,请参见beforeLoad
的帮助页面。这是beforeLoad
个限制的摘要:
第二个要点是与您的问题有关的问题。
答案 1 :(得分:1)
newRecord.setValue
无法在beforeLoad中使用。如果像下面这样使用newRecord.submitFields
newRecord.submitFields({
id: newRecord.id,
type: newRecord.type,
values: {'memo', 'this is a test'}
});
希望有帮助!