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

Netsuite 从销售订单到物料履行的转换错误,netsuite,suitescript2.0,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; va

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

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

我一直遇到这个错误,这有点让人困惑,因为我不知道他们所说的“堆栈”是什么意思:


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

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

查看记录浏览器,我在履行标题上看不到任何位置字段 这应该起作用:-

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();
}
提交后的函数(上下文){
var orderId=context.newRecord.id;
var fulfillmentRecord=record.transform({
fromType:record.Type.SALES\u ORDER,
fromId:orderId,
toType:record.Type.ITEM_履行,
isDynamic:对
});
var lineCount=fulfillmentRecord.getLineCount({sublistId:'item});
对于(var i=0;i
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();
}