如何在库存明细子记录上设置序列号/批号的值?

时间:2019-08-30 17:00:22

标签: netsuite restlet suitescript2.0

我已经尽一切努力使此工作正常进行,但是无论我做什么,我总是会从NetSuite收到以下错误:

error code: USER_ERROR error message: {"type":"error.SuiteScriptError","name":"USER_ERROR","message":"Please enter value(s) for: Serial/Lot Number","stack":["anonymous(N/serverRecordService)"...

当我尝试提交该行时会发生这种情况。

我正在尝试做的事情(在RESTlet中)是以编程方式为现有工单(WO)创建工单完成(WOC)。我有它为第一次手术工作。但是,对于需要库存明细的最终操作,我得到了错误。这是我的代码(为了更清楚起见,我删除了错误检查等):

/**
* @NApiVersion 2.x
* @NScriptType restlet
*/
define(['N/runtime', 'N/error', 'N/record', 'N/search'], function(runtime, error, record, search) {

  return {
    get : function(datain) {

        var wo = record.load({
            type: record.Type.WORK_ORDER,
            id: datain.woid
        });

        var woc = record.transform({
            fromType: record.Type.WORK_ORDER,
            fromId: datain.woid,
            toType: record.Type.WORK_ORDER_COMPLETION,
            isDynamic: true,
            defaultValues: {
              isbackflush: 'F',
            }
        });
        woc.setText({
            fieldId: "startoperation",
            text: "20"
        });
        woc.setText({
            fieldId: "endoperation",
            text: "20"
        });
        woc.setText({
            fieldId: "completedquantity",
            text: "230"
        });

        var invdetail = woc.getSubrecord({
          fieldId: "inventorydetail"
        });

        invdetail.selectNewLine({
          sublistId: "inventoryassignment",
        });
        invdetail.setCurrentSublistValue({
          sublistId: "inventoryassignment",
          fieldId: "binnumber",
          value: 29
        });
        invdetail.setCurrentSublistValue({
          sublistId: "inventoryassignment",
          fieldId: "quantity",
          value: 230
        });
        invdetail.setCurrentSublistText({
          sublistId: "inventoryassignment",
          fieldId: "issueinventorynumber",
          text: "abc"
        });
        invdetail.commitLine({
          sublistId: "inventoryassignment",
        });

        woc.save();

        var results = {
            woc: woc
        };

        return JSON.stringify(results);
    }
  }
});

我已尽我所能想到的一切。使用setCurrentSublistValue()和setCurrentSublistText(),将值设置为现有批次,新批次等。

但是,无论我做什么,NS总是以“请输入以下值:序列号/批号”作为响应,就像未设置一样。

想法,想法,建议???

谢谢!

1 个答案:

答案 0 :(得分:1)

尝试将receiptinventorynumber用作fieldId。

invdetail.setCurrentSublistValue({
                    sublistId: 'inventoryassignment',
                    fieldId: 'receiptinventorynumber',
                    value: 'lotNumber'
                });
invdetail.commitLine({sublistId: 'inventoryassignment'});