how to update the inventory item's vendor price us...
# ask-stanley-ai
s
how to update the inventory item's vendor price using suitescript 2.1(not adding a new vendor price, updating exsting vendor's price)
c
AI generated answer (using internal Slack threads):
To update the inventory item's vendor price using SuiteScript 2.1, you need to access the vendor price through a subrecord. The vendor price is not directly a field on the sublist, but is represented by a subrecord. Here is a sample code snippet that demonstrates how to do this:
Copy code
javascript
itemRecord.selectLine({
    sublistId: 'itemvendor',
    line: i
});

var vendorSubrecord = itemRecord.getCurrentSublistSubrecord({
    sublistId: 'itemvendor',
    fieldId: 'itemvendorprice'
});

vendorSubrecord.setValue({
    fieldId: 'vendorprice',
    value: tradePrice
});

itemRecord.commitLine({ sublistId: 'itemvendor' });
In this code snippet,
itemvendor
is the sublistId for the vendor sublist,
i
is the line number,
itemvendorprice
is the fieldId for the vendor price subrecord, and
tradePrice
is the new price you want to set. Please note that the price is on the
itemvendorpricelines
sublist, with each line representing a different currency. This is similar to the subrecord in the UI. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.825622618
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.824157715
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.818847656
Please provide your feedback on this answer.