netsuite - Suitescript 2.0 中无法创建笔记记录,但 1.0 中可以

标签 netsuite suitescript2.0

任何人都知道为什么在客户端 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/

相关文章:

Netsuite从帐户表获取[货币]的方法

python - 使用python从netsuite获取和推送数据

javascript - 在 SuiteScript 2.0 中从客户端脚本设置内联 HTML 字段

installation - 在Eclipse设备上安装SuiteCloud IDE的URL是什么?

web-services - NetSuite Suitelet 根据保存的搜索或自定义字段添加选择字段

html - 我可以使用 Bootstrap for Netsuite 在 Suitelet 中创建自定义表单吗?

javascript - 在 SuiteScript 中提取 JSON 数据时出现问题 - NetSuite

javascript - Suitescript 2.0 ResultSet.Each 回调函数超过 4000

javascript - 如何使用 SuiteScript 2.0 将文件从本地上传到 NetSuite 文件柜

netsuite - SuiteScript hmac sha256