我尝试将新创建的销售订单转换为发票时出错。
这是我的代码:
define(["N/log", "N/email", "N/record"], function(log, email, record) {
function afterSubmit(scriptContext) {
var newOrderId = scriptContext.newRecord.id;
var objRecord = record.transform({
fromType: record.Type.SALES_ORDER,
fromId: newOrderId,
toType: record.Type.INVOICE,
isDynamic: true
});
以下是错误详情:
Account: 3671783
Environment: SandBox
Date & Time: 6/28/2017 2:09 am
Record Type: Sales Order
Internal ID: 668978
Execution Time: 0.00s
Script Usage: 0
Script: test send invoice
Type: User Event
Function: afterSubmit
Error: JS_EXCEPTION
{"type":"error.SuiteScriptError","name":"INVALID_INITIALIZE_REF","message":"You can not initialize invoice: invalid reference 668978.","stack":["createError(N/error.js)","afterSubmit(/SuiteScripts/sendinvoice1.js:23)"],"cause":{"type":"internal error","code":"INVALID_INITIALIZE_REF","details":"You can not initialize invoice: invalid reference 668978.","userEvent":"aftersubmit","stackTrace":["createError(N/error.js)","afterSubmit(/SuiteScripts/sendinvoice1.js:23)"],"notifyOff":false},"id":"","notifyOff":false}
我不知道自己做错了什么。
答案 0 :(得分:3)
当您尝试转换时,销售订单处于什么状态?在发票SO之前,在某些条件下必须满足一些标准: