Mark Ford
Mark Ford

Reputation: 152

How do I set the value for Serial/Lot Number on an Inventory Detail Subrecord?

I have tried everything to get this working but no matter what I do, I always get the following error from 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)"...

This occurs when I try to commit the line.

What I am attempting to do (in a RESTlet) is programatically create a Work Order Completion (WOC) for an existing Work Order (WO). I have it working for the first operation. However, for the final operation, which requires an Inventory Detail, I am getting the error. Here is my code (I have removed error checking, etc for better clarity):

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

I have tried everything I can think of. Using setCurrentSublistValue() and setCurrentSublistText(), setting the value to an existing lot, new lot, etc, etc.

However, no matter what I do, NS always responds with the "Please enter value(s) for: Serial/Lot Number" error as if it is not set.

Thoughts, ideas, suggestions???

Thanks!

Upvotes: 0

Views: 4418

Answers (1)

ehcanadian
ehcanadian

Reputation: 1784

Try using receiptinventorynumber for your fieldId.

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

Upvotes: 2

Related Questions