Transform sales order to invoice error

杀马特。学长 韩版系。学妹 提交于 2019-12-25 09:41:43

问题


I'm having an error when I try to transform a newly created sales order to an invoice.

Here's my code:

  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
        });

Here's the error details:

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}

I don't know what am I doing wrong.


回答1:


What status is the Sales Order in when you're trying to transform it? Before you can Invoice an SO, there are some criteria that must be met under certain conditions:

  • If you have Approvals on for Sales Orders, then your SO must be Approved before you can Invoice it.
  • If any of the Items on the SO are fulfillable, then the Order must be fulfilled (i.e. have an associated Item Fulfillment) before you can Invoice it
    • UNLESS you have the INVOICE IN ADVANCE OF FULFILLMENT setting enabled (Setup > Accounting > Accounting Preferences > Order Management > Invoicing), then you can forego the Item Fulfillment


来源:https://stackoverflow.com/questions/44784013/transform-sales-order-to-invoice-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!