我刚接触suitescript,正在尝试通过suitescript将我们的“度量单位”迁移到netsuite。
我认为设置按需脚本执行的最好方法是在用户事件脚本上设置“AfterSubmit”,对吗?我查看了一个调度脚本,但它并不是真正按需运行,因为它会等待调度程序。
我的'After Submit‘函数目前看起来像这样。我正在尝试在列表>会计>度量单位(单位类型)下创建一条记录
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."
这是因为我需要在子列表中至少有一项吗?有人能帮我指出创建子列表项所需的语法吗?
发布于 2021-07-21 05:54:36
我认为用例决定了“设置按需脚本的最佳方式”。就我个人而言,我会创建一个预定的或映射/还原脚本,并通过使用UI中脚本部署或task.create (从另一个脚本触发)上的“保存和执行”功能来触发它按需运行。也可以使用浏览器控制台执行脚本。
为了解决您收到的错误,可以引用Suite Answer Id 45152,defaultValues参数只适用于特定的记录和字段。单位类型不是支持记录。因此,您需要创建记录,设置所有必需的值,然后保存记录。
要创建新的度量单位,应执行以下操作
//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
https://stackoverflow.com/questions/68460582
复制相似问题