netsuite - Netsuite:“INVALID_RCRD_INITIALIZE”,“message”:“您为此记录初始化操作输入了无效的默认值。”
问题描述
我是suitescript的新手,并试图通过suitescript将我们的“度量单位”迁移到netsuite。
我相信设置按需脚本执行的最佳方法是在用户事件脚本上“提交后”,这准确吗?我查看了一个预定的脚本,但它并没有真正按需运行,因为它等待调度程序。
我的“提交后”功能目前看起来像这样。我正在尝试在列表 > 会计 > 计量单位(单位类型)下创建记录
const afterSubmit = (scriptContext) => {
var unittype = record.create({ type: 'unitstype', defaultValues: { name: 'Weights' } }); }
当我运行脚本时,我收到此错误:
{"type":"error.SuiteScriptError","name":"INVALID_RCRD_INITIALIZE","message":"You have entered an invalid default value for this record initialize operation."
那是因为我需要子列表中的至少一项吗?谁能帮我指出创建子列表项所需的语法?
解决方案
我认为用例决定了“设置按需脚本的最佳方式”。就我个人而言,我会制作一个 Scheduled 或 Map/Reduce 脚本,并通过在 UI 中的脚本部署或 task.create(从另一个脚本中触发它)上使用“保存并执行”功能来触发它以按需运行。也可以使用浏览器控制台执行脚本。
要解决您收到的错误,defaultValues 参数仅适用于特定记录和字段,可以参考Suite Answer Id 45152。单位类型不是支持记录。所以你需要创建记录,设置所有需要的值,然后保存记录。
要创建一个新的度量单位,以下应该工作
//create record
var newRec = record.create({
type: 'unitstype',
isDynamic: //optional
});
//set all desired main line/area values
newRec.setValue({
fieldId: 'name',
value: 'Weights',
ignoreFieldChange: true //Optional, if set to true, the field change and the secondary event is ignored. default is false
});
//set sublist values, if in standard mode
newRec.setSublistValue({
sublistId: 'uom', //Units in the UI
fieldId: '', //will need to set all the required sublist fields
line: 0,
value:
});
//set sublist values, if in dynamic mode
newRec.selectLine({
sublistId: 'item',
line: 3
});
newRec.setCurrentSublistValue({
sublistId: 'uom',
fieldId: '',
value: ,
ignoreFieldChange: true
});
newRec.commitLine({
sublistId: 'uom'
});
//save record for either mode
var newRecId = newRec.save({
enableSourcing: true, //Optional, if set to true, sources dependent field information for empty fields. default is false
ignoreMandatoryFields: true //Optional, if set to true, all standard and custom fields that were made mandatory through customization are ignored. default is false
});
有关动态和标准记录的更多信息,可以参考Suite Answer Id 73792
推荐阅读
- ruby - 如何使用 Nokogiri 获取标签
- swift - Swift 命令行异步不等待
- python - 使用 Pathlib 搜索匹配的文件?
- javascript - 单击更改图像 - 反应
- javascript - 无法获取查询字符串数据
- c# - 尝试从 ASP.NET CORE 中的 URL 读取 XML 时出错
- java - 如何在字符串java中附加升序数字
- tensorflow - 如何使用tensorflow xla aot模式搭建CNN模型?
- excel-formula - Excel - 将 6 个月添加到日期,然后四舍五入到最近的季度
- .htaccess - htaccess 重写规则子文件夹