任何人都知道为什么在客户端 SuiteScript 2.0 中,此代码给出错误“无效的事务引用 key 8355”,但当我在 1.0 版本中运行相同的调用时,它可以工作。有人知道为什么吗?
SuiteScript 2.0(失败)
require(['N/record'], function(record){
var note = record.create({type: 'note'});
note.setValue({fieldId: 'title', value: 'Test'});
note.setValue({fieldId: 'note', value: 'note description'});
note.setValue({fieldId: 'notetype', value: 7});
note.setValue({fieldId: 'transaction', value: 8355});
note.save();
})
SuiteScript 1.0(有效)
var record = nlapiCreateRecord('note');
record.setFieldValue('title', 'Test' );
record.setFieldValue('note', 'note description');
record.setFieldValue('notetype',7 );
record.setFieldValue('transaction',8355);
var recordId = nlapiSubmitRecord(record);
1.0 客户端 SuiteScript 运行良好。
最佳答案
我可以确认我刚刚完全使用了您的代码(除了切换注释类型和交易字段以匹配我的帐户)并且它运行良好。我在控制台中对销售订单执行了测试,因此它应该在客户端套件脚本中正常工作。您收到的错误是什么?我会仔细检查您的票据类型和交易值(value)是否有效。另外,您的脚本部署是什么样的,也许那里有问题?
另一件事,您在代码块末尾缺少“)”,但我认为这是复制粘贴错误。
这对我有用:
require(['N/record'], function (record) {
var note = record.create({type: 'note'});
note.setValue({fieldId: 'title', value: 'Test'});
note.setValue({fieldId: 'note', value: 'note description'});
note.setValue({fieldId: 'notetype', value: 7});
note.setValue({fieldId: 'transaction', value: 453});
note.save();
});
关于netsuite - Suitescript 2.0 中无法创建笔记记录,但 1.0 中可以,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51790216/