Anyone notice the documentation is missing (as far...
# suitescript
e
Anyone notice the documentation is missing (as far back as I can tell) for this in the Records Browser? https://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2022_2/script/record/itemvendorprice.html “HTTP method GET is not supported by this URL” This is for the subrecord on the Inventory Part
In this vein, though, I am having trouble writing to the Vendor Prices sublist on an Item. I get the following error:
Copy code
message: "Invalid vendorcurrency reference key 4."
name: "INVALID_KEY_OR_REF"
b
make the vendor that you are trying to create in the ui
then load it in script so that you can inspect the vendor price subrecord to se what it looks like
e
thanks. i did this in the ui first, then am testing by loading that exact item and simply editing the first line in the subrecord. trying to play it as safe as possible. even when I just edit the Vendor Price as below, it for some reason complains about missing the currency (even though I’m editing the line and currency is saved on that line)
SUBREC.setSublistValue({ sublistId: 'itemvendorpricelines', fieldId: 'vendorprice', line: 0, value: 1000 });
and yes i inspected it (just wanted to let NS know that the docs are - and seemingly always have been - missing this)
b
what does the subrecord look like while inspecting it
e
var REC = record.load({ type: record.Type.INVENTORY_ITEM, id: 96946 }); console.log(‘vendorcurrencyname’, REC.getSublistValue({ sublistId: ‘itemvendor’, fieldId: ‘vendorcurrencyname’, line: 0 })); var vendor = REC.getSublistValue({ sublistId: ‘itemvendor’, fieldId: ‘vendor’, line: 0 }); var preferred = REC.getSublistValue({ sublistId: ‘itemvendor’, fieldId: ‘preferredvendor’, line: 0 }); var SUBREC = REC.getSublistSubrecord({ sublistId: ‘itemvendor’, fieldId: ‘itemvendorprice’, line: 0}); var currency = Number(SUBREC.getSublistValue({ sublistId: ‘itemvendorpricelines’, fieldId: ‘vendorcurrency’, line: 0 })); var price = SUBREC.getSublistValue({ sublistId: ‘itemvendorpricelines’, fieldId: ‘vendorprice’, line: 0 }); console.log(vendor, preferred); console.log( currency, price); SUBREC.setSublistValue({ sublistId: ‘itemvendorpricelines’, fieldId: ‘vendorprice’, line: 0, value: 1000 }); SUBREC.setSublistValue({ sublistId: ‘itemvendorpricelines’, fieldId: ‘vendorcurrency’, line: 0 , value:currency }); REC.save();
(doing this in the console - could that be my issue???) i can read in the currency, and actually used that exact value for currency to set the vendorcurrency (with or without wrapping it in Number as you see above) and still failed
b
there are 2 choices you have
you can log your subrecord into the console
or you can use the debugger to see what the subrecord should look like
e
i was jsut logging into Script Debugger
My problem isn’t inspecting the record anymore; my problem here is that it errors out when writing to the currency field on that subrecord.
it errors out on this line
SUBREC.setSublistValue({ sublistId: 'itemvendorpricelines', fieldId: 'vendorcurrency', line: 0 , value:currency });
b
are you trying to create or edit your item
e
here i am editing just for trial (prob will use this on create later once i get it working)
here’s the stringified value of the subrecord’s sublist
b
you would probably have an easier time creating a new item
e
i see currency is a string value ‘4’ - but even when writing that to the line, it’s too tough. Hmm. I’ll try create, thanks. Get back to you later @battk thanks for your help!
b
you are trying to do an operation that you couldnt actually do in the ui
e
of course i can…
?
b
you wouldnt be able to set the currency field to the same value
e
i edit the item, pop up the prices, and boom
?
same line
b
you arent changing the currency field to the same value
its something you cant actually in the ui
e
i TRIED to simply edit the price, and it barked
either way, i tried also to ADD the line (before it existed), but it also didn’t accept. my whole entire issue is the fact that it is rejecting my Currency value and i don’t know why
i may be better off in create mode
b
what you shared so far looks to be an attempt at adding multiple lines with the same currency
you cant actually do that in the ui
e
works in create mode, so we can set this to sleep. who is in charge of documentation though? Records Browser is indeed broken (broken link)
thanks @battk again!