Попробуйте создать инвентаризационную квитанцию ​​в suitescript 2.0, сохраните ошибку field.getSublistName - PullRequest
0 голосов
/ 06 октября 2018

Я пытаюсь сделать инвентаризацию через свой пользовательский тип записи.Основная процедура заказа на покупку создаст пользовательский тип записи, затем пользовательский тип записи создаст запись поступления товара.Вот мой код.

function saveRecord(scriptContext) {

    var curRec = scriptContext.currentRecord;
    var poId = curRec.getValue({
        fieldId : 'custrecord_qms_insp_source_doc'
    });

    var itemId = curRec.getValue({
        fieldId : 'custrecord_qms_insp_item'
    });

    var poRec = record.load({
        type : record.Type.PURCHASE_ORDER,
        id : poId
    });

    var itemReceipt = record.transform({
        fromType : record.Type.PURCHASE_ORDER,
        fromId : poId,
        toType : record.Type.ITEM_RECEIPT,
        isDynamic : false
    });

    itemReceipt.setValue({
        fieldId : 'exchangerate',
        value : 1
    });

    itemReceipt.setValue({
        fieldId : 'customform',
        value : 39
    });

    var today = new Date();

    itemReceipt.setValue({
        fieldId : 'trandate',
        value : today
    });

    itemReceipt.setSublistValue({
        sublistId : 'item',
        fieldId : 'location',
        line : 0,
        value : 4
    });

    itemReceipt.setSublistValue({
        sublistId : 'item',
        fieldId : 'quantity',
        line : 0,
        value : 2
    });

    var itemSubrecord = itemReceipt.getSublistSubrecord({
        sublistId : 'item',
        line : 0,
        fieldId : 'inventorydetail'
    });

    itemSubrecord.insertLine({
        sublistId : 'inventoryassignment',
        line : 0
    });

    itemSubrecord.insertLine({
        sublistId : 'inventoryassignment',
        line : 0
    });

    itemSubrecord.setSublistValue({
        sublistId : 'inventoryassignment',
        fieldId : 'quantity',
        line : 0,
        value : 2
    });

    itemReceipt.save();

}

return {
    saveRecord : saveRecord
};

Когда я запускаю его, он продолжает показывать сообщение об ошибке: "TypeError: field.getSublistName is not a function".Я понятия не имею, почему это сообщение показывает и как его решить.Любая помощь будет оценена.

...