shawleigh17
shawleigh17

Reputation: 1187

Get the name of a sublist in Netsuite?

Is there a way to get the name of a sublist in Netsuite? I am using the new Inbound Shipment section, and I need to add items to it via a restlet. Every time I try, I get this error:

{"type":"error.SuiteScriptError","name":"SSS_INVALID_SUBLIST_OPERATION","message":"You have attempted an invalid sublist or line item operation. You are either trying to access a field on a non-existent line or you are trying to add or remove lines from a static sublist.","stack":["anonymous(N/recordService)","<anonymous>(/SuiteScripts/KK_Sandbox_Scripts_SD/RestLets/InboundShipment.js:57)","doPost(/SuiteScripts/KK_Sandbox_Scripts_SD/RestLets/InboundShipment.js:34)"],"cause":{"type":"internal error","code":"SSS_INVALID_SUBLIST_OPERATION","details":"You have attempted an invalid sublist or line item operation. You are either trying to access a field on a non-existent line or you are trying to add or remove lines from a static sublist.","userEvent":null,"stackTrace":["anonymous(N/recordService)","<anonymous>(/SuiteScripts/KK_Sandbox_Scripts_SD/RestLets/InboundShipment.js:57)","doPost(/SuiteScripts/KK_Sandbox_Scripts_SD/RestLets/InboundShipment.js:34)"],"notifyOff":false},"id":"","notifyOff":false}"

This is how I am trying to access it:

var rec =
            r.create({
                type: "inboundshipment",
                isDynamic: true,
                defaultValues: null
            }).setValue({
                fieldId: "externalid",
                value: e.id,
                ignoreFieldChange: false
            });

        var i = 1;

        /******/
        //Here is where you are adding a new line.
        /******/
        rec.selectNewLine({
            sublistId: 'item'
        });
        rec.setCurrentSublistValue({
            sublistId: 'item',
            fieldId: 'po',
            value: "13193"
        });
        rec.setCurrentSublistValue({
            sublistId: 'item',
            fieldId: 'item',
            value: "79760"
        });
        rec.setCurrentSublistValue({
            sublistId: 'item',
            fieldId: 'quantity',
            value: 2
        });

I think the sublist id might be incorrect, but I can't figure out what it should be. I have tried items, inbounditems, inboundshipmentitems, and all of them give me the same error. I tried to create a sales order in the same fashion and tried to add items to it, and it worked properly, so I am thinking it is just the sublist id. Anyone know how to help?

Upvotes: 1

Views: 4943

Answers (1)

Krypton
Krypton

Reputation: 5231

You can retrieve the sublist ids using Record.getSublists() and log that to make sure you have a valid sublist ID.

I suspect this could be related to a SuiteScript 2.0 bug, so check with NetSuite and try rewriting it in SuiteScript 1.0.

Upvotes: 2

Related Questions