I am trying to create new inventory items via a su...
# suitescript
a
I am trying to create new inventory items via a suitelet, but I am running into issues with the price level sublist. The longer I look at this and search NetSuite support docs, the more confused I get. Can anyone point me in the correct direction? (we do utilize pricing breaks) _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.",_
Copy code
var newItem = record.create({
                type: record.Type.INVENTORY_ITEM,
                isDynamic: true
            });

            newItem.selectNewLine({
                sublistId: 'price'
            });
            newItem.setCurrentSublistValue({
                sublistId: 'price',
                fieldId: 'pricelevel',
                value: 1 // Base Price
            });
            newItem.setCurrentSublistValue({
                sublistId: 'price',
                fieldId: 'price',
                value: sellpricefield
            });
            newItem.commitLine({
                sublistId: 'price'
            });

            var recordId = newItem.save();
b
a
Copy code
newItem.selectLine({ 
                sublistId: 'price1',
                line: 1
            });
            newItem.setCurrentMatrixSublistValue({
                sublistId: price1,
                fieldId: 'price',
                column: 1,
                value: sellpricefield
            });
            newItem.commitLine({ sublistId: 'price1' });
ReferenceError: "price1" is not defined. Although, reading that page, that should be correct.
b
your second sublistId is a variable, not a string
🙌 1
a
I'm obviously blind.
👀 1
b
ReferenceError in general mean a variable is missing
or in this case you used a variable without meaning to
a
That pricing sublist page is a bit outdated as well. Their way to finding the pricing matrix row/column is incorrect. They count the discount row and column as 0, but it is not.
base price and first quantity break is 0
Appreciate the help @battk!
b
the ordering of price levels will be different per account
and can actually change over time
dont rely on the order of the price levels, find it yourself
in general, if your field id is not price, you dont use the pricing matrix