Преобразование из заказа на продажу в ошибку выполнения номенклатуры

У меня возникли проблемы с преобразованием заказа на продажу в выполнение номенклатуры. Вот мой код:

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

person CodeMonkey    schedule 09.07.2018    source источник


Ответы (3)


Глядя в браузер записей, я не вижу ни одного поля местоположения в заголовке выполнения 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();
}
person M. Saqib Arfeen    schedule 02.10.2020

Я вижу, что вы установили поле местоположения в заголовке, но на основании ошибки вам также нужно будет установить поле местоположения в подсписке элементов.

person Rusty Shackles    schedule 09.07.2018

Эта ошибка возникает, когда Netsuite не может получить значение, которое вы назначаете в сценарии. Местоположение — тип списка/записи. И вы устанавливаете местоположение на основе значения. Попробуйте использовать setText вместо setValue.

person SahooCodex    schedule 18.07.2018