Why is the vendor purchase price not being updated...
# ask-stanley-ai
j
Why is the vendor purchase price not being updated through REST but when adding a new vendor, the vendor purchase price is set? We have multi-currency
c
AI generated answer (using internal Slack threads):
The vendor purchase price is not being updated through REST because when multi-currency is enabled, the vendor purchase price is not directly a field on the vendor sublist. Instead, it is represented by a subrecord. This is why you are able to set the vendor purchase price when adding a new vendor, but not when trying to update an existing vendor's purchase price. In the UI, you would click a button to edit a subrecord. The same process needs to be followed in the script. You need to select the line, get the current sublist subrecord, and then set the value. Here is a sample code snippet that demonstrates this:
Copy code
javascript
itemRecord.selectLine({
    sublistId: vendorSublist,
    line: i
});

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

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

itemRecord.commitLine({ sublistId: vendorSublist });
In this code,
vendorSublist
is the ID of the vendor sublist,
i
is the line number, and
tradePrice
is the new purchase price. Remember, the price is on the
itemvendorpricelines
sublist, with each line representing a different currency, the same as 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.810897529
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.810768306
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.807248771
Please provide your feedback on this answer.