can someone help me with this script error? TypeE...
# suitescript
l
can someone help me with this script error? TypeError: Cannot find function setSublistValue in object dynamic record.
n
Yeah how are you getting the record that you are trying to set the value on?
l
Copy code
var item_record = record.load({
                       type: record.Type.INVENTORY_ITEM,
                       id: item_id,
                       isDynamic: true,
                   });

 item_record.setSublistValue({
                            sublistId: 'price1',
                            fieldId: 'price_1_',
                            line: 10,
                            value: display_price
                        });
n
Try this
Copy code
var item_record = record.load({
                       type: record.Type.INVENTORY_ITEM,
                       id: item_id,
                       isDynamic: true,
                   });
 item_record.selectLine({sublistId: 'price1', line: 10})
 item_record.setCurrentSublistValue({
                            sublistId: 'price1',
                            fieldId: 'price_1_',
                            value: display_price
                        });
l
do i need to commit line after?
n
I think setSublistValue is for static records.
yes
oh alternatively you could just set the isDynamic to false.
l
im getting unexpexted error when i do that
dynamic: false
n
Sorry. Dynamic false with your original code. Dynamic true with the code i put in
l
yes exactly - dynamic false with my original code im getting unexpected error
r
Isn't setSublistValue works with a standard record? And for dynamic we have to use selectLine, setCurrentSublistValue and commitLine?
e
Yes, you want to update matrix
n
^^ beyond that It seems like you need to familiarise yourself with working with sublists and subrecords and more specifically the difference between a a record that is in dynamic mode and one that is not.