我正在 Netsuite 中创建一个使用 2.0 版本 API 的 Scheduled SuiteScript。
我想创建记录,但发生了一些错误。
脚本是:
/**
*@NApiVersion 2.x
*@NScriptType ScheduledScript
*@author Sheldor Qu
*@description 此脚本用于每天定时更新采购价格税率维护表
*@version V1.0.0
*/
define(['N/record'], function (record) {
function execute(context) {
try {
var customTaskRecord = record.create({
type: 'customrecord_tp_dev_task',
isDynamic: true,
});
log.debug('new customTaskRecord', customTaskRecord);
} catch (error) {
log.debug('error', error);
}
}
return {
execute: execute
}
});
错误信息是:
{
"type": "error.SuiteScriptError",
"name": "SSS_MISSING_REQD_ARGUMENT",
"message": "task.checkStatus: Missing a required argument: options.taskId",
"stack": [
"createError(N/error)",
"execute(/SuiteScripts/Scheduled Script/TP_SS_PurchasePriceUpdDaily.js:12)"
],
"cause": {
"type": "internal error",
"code": "SSS_MISSING_REQD_ARGUMENT",
"details": "task.checkStatus: Missing a required argument: options.taskId",
"userEvent": null,
"stackTrace": [
"createError(N/error)",
"execute(/SuiteScripts/Scheduled Script/TP_SS_PurchasePriceUpdDaily.js:12)"
],
"notifyOff": false
},
"id": "",
"notifyOff": false,
"userFacing": false
}
我不知道为什么,请帮助我。
我相信您在尝试检查任务状态的另一个脚本中收到了错误。
var taskStatus = task.checkStatus(taskId);
但taskId为空或未定义或丢失。 确保脚本在提交任务时设置一个可用作任务 ID 的变量。
var taskId = scriptTask.submit();
请帮助我解决这个问题,我是 SuiteScript 的新手
/**
define(['N/记录'],
/** *
@param {record} 记录 */ 函数(记录){
返回{
afterSubmit : function (context) {
// log.debug('BismiAllah');
var employee = context.newRecord;
var empCode = employee.getValue({fieldId:'custentity_ms1_employee_code'});
var supervisorId = employee.getValue({fieldId:'supervisor'}); // regular filed return internal id
var supervisorName = employee.getValue({fieldId:'supervisor'});
var userName = employee.getValue({fieldId:'firstname'});
log.debug('Empoloyee Code', empCode);
log.debug('Supervisor ID', supervisorId);
log.debug('Supervisor Name', supervisorName);
log.debug('First Name', userName);
if (context.type == context.UserEventType.CREATE) {
var phoneCall = record.create ({
type : record.Type.PHONE_CALL
// using standard form getting value from define/form. comma will put after PHONE_CALL,
,
// defaultValues : {
// customform : -150
// }
});
phoneCall.setValue({fieldId:'title', value:'Call HR for benefits'});
phoneCall.setValue({fieldId: 'assigned', value:employee.id});
var id = phoneCall.save({ignoreMandatoryFields:true});
log.debug('phone Call id', id);
var event = record.create({
type : record.Type.EVENT,
isDynamic : true
});
event.setValue('title', 'Wecome meeting with supervisor');
event.selectNewLine({sublistId : 'attendee'});
event.setCurrentSublistValue({
sublistId : 'attendee',
fieldId : 'attendee',
value : employee.id
});
event.commitLine({sublistId : 'attendee'});
event.setCurrentSublistValue({
sublistId : 'attendee',
fieldId : 'attendee',
value : employee.getValue('supervisor')
});
event.commitLine({sublistId : 'attendee'});
event.save();
}
}
};
});