从销售订单到物料履行错误的转换

时间:2018-07-09 03:12:48

标签: netsuite suitescript2.0

我在将销售订单转换为项目履行时遇到了一些麻烦。这是我的代码:

/**
 * @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}

3 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

当Netsuite无法获取您在脚本中分配的值时,将出现此错误。位置是列表/记录类型。并且您正在根据值设置位置。尝试使用setText代替setValue。

答案 2 :(得分:0)

在记录浏览器中,我看不到实现标题https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2020_1/script/record/itemfulfillment.html上的任何位置字段 这应该起作用:-

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
    });
    var lineCount = fulfillmentRecord.getLineCount({sublistId:'item});
    for(var i=0;i<lineCount; i++){
    fulfillmentRecord.selectLine({sublistId:'item',line:i});
    fulfillmentRecord.setCurrentSublistValue({
        sublistId:'item',
        fieldId: 'location',
        value: '123' //Enter the location internal id, instead of name i.e San Francisco
    });
    }
    log.error({
        title: 'Debug Entry',
        details: fulfillmentRecord
    });
    var rid = fulfillmentRecord.save();
}
相关问题