首页 > 解决方案 > 从销售订单到项目履行错误的转换

问题描述

我在将销售订单转换为商品履行时遇到了一些问题。这是我的代码:

/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 * @NModuleScope SameAccount
 */
define(['N/record', 'N/log'],
function(record, log) {
function afterSubmit(context) {
    var orderId = context.newRecord.id;

    var fulfillmentRecord = record.transform({
        fromType: record.Type.SALES_ORDER,
        fromId: orderId,
        toType: record.Type.ITEM_FULFILLMENT,
        isDynamic: true
    });
    fulfillmentRecord.setValue({
        fieldId: 'location',
        value: 'San Francisco'
    });
    log.error({
        title: 'Debug Entry',
        details: fulfillmentRecord
    });
    var rid = fulfillmentRecord.save();
}
return {
    afterSubmit: afterSubmit
};

});

我不断收到此错误,这有点令人困惑,因为我不知道“堆栈”是什么意思:

{"type":"error.SuiteScriptError",
"name":"USER_ERROR",
"message":"Please provide values for the following fields in the Items list: Location",
"stack":["anonymous(N/serverRecordService)",
"afterSubmit(/SuiteScripts/fulfillmentCreator.js:23)"],
"cause":{
"type":"internal error",
"code":"USER_ERROR",
"details":"Please provide values for the following fields in the Items list: Location",
"userEvent":"aftersubmit",
"stackTrace":["anonymous(N/serverRecordService)","afterSubmit(/SuiteScripts/fulfillmentCreator.js:23)"],"notifyOff":false},"id":"","notifyOff":false}

标签: netsuitesuitescript2.0

解决方案


我看到您已经在标题处设置了位置字段,但根据错误,您还需要在项目子列表上设置位置字段。


推荐阅读