Jira Code : BGGN-529
Scenario
When multiple Vendors are enabled, item vendors are now their own subrecord, and the prices under it opens up another table so the user cannot simply use record.SetSublistValue() to set the item vendor’s data. This article shows how to edit the purchase price subrecord via script.
Note: This is only possible using a server side script.
Solution
1. Create the code below as a scheduled script.
require('N/record'],
function(record) {
function editItemVendorPrice(){
var itemRecord = record.Load({
type: record.Type.INVENTORY_ITEM,
id: 16,
isDynamic: true
}); // load item
itemRecord.selectLine({
sublistId: 'itemvendor',
line: 1
}); //select item vendor
var vendor = itemRecord.getCurrentSublistSubrecord({
sublistId: 'itemvendor',
fieldId: 'itemvendorprice'
});
vendor.selectLine({
sublistId:"itemvendorpricelines",
line: 1
});
vendor.setCurrentSublistValue({
sublistId: "itemvendorpricelines",
fieldId: "vendorprice",
value: 1000
});
vendor.commitLine({
sublistId:"itemvendorpricelines"
});//commit the item vendor price line.
itemRecord.commitLine({
sublistId: "itemvendor"
}); // commit item vendor
itemRecord.save(); //submit item record
}
})
2. Deploy the scheduled script
3. Click Save & Execute