I'm getting the following error:
"Drop ship/Special order items must have a preferred vendor and purchase price."
From this SuiteScript function which contains value assignments for preferred vendor and purchase price. So, there must be something wrong with the way I'm setting/creating the itemvendor sublist?
function createItemRecord(item, vendor, subsidiary) {
log.audit({
title: 'createItemRecord...',
details: {ITEM: item, VENDOR: vendor, SUBSIDIARY: subsidiary}
});
var itemRecord = record.create({
type: record.Type.INVENTORY_ITEM,
isDynamic: true
});
itemRecord.setValue({
fieldId: "itemid",
value: item.sku
}).setValue({
fieldId: "displayname",
value: item.summary
}).setValue({
fieldId: "purchasedescription",
value: item.details
}).setValue({
fieldId: "isspecialorderitem",
value: true
}).setValue({
fieldId: "cost",
value: item.price
});
itemRecord.selectNewLine({
sublistId: 'itemvendor'
});
itemRecord.setCurrentSublistValue({
sublistId: 'itemvendor',
fieldId: 'vendor',
value: vendor
});
/* vendor.internalId */
itemRecord.setCurrentSublistValue({
sublistId: 'itemvendor',
fieldId: 'purchaseprice',
value: item.price
});
itemRecord.setCurrentSublistValue({
sublistId: 'itemvendor',
fieldId: 'subsidiary',
value: subsidiary.internalId
});
itemRecord.setCurrentSublistValue({
sublistId: 'itemvendor',
fieldId: 'preferredvendor',
value: true
});
itemRecord.commitLine({
sublistId: 'itemvendor'
});
itemRecord.save({
enableSourcing: true,
ignoreMandatoryFields: false
});
}
The audit log message at the start of the function indicates the following values are being passed in to the function:
{"ITEM":{"sku":"SKU #1","catalogcode":"1804","summary":"Billiard Table","details":"Billiard Table","price":9999.99}, "VENDOR":"1648", "SUBSIDIARY":{"internalId":"3","externalId":"","type":"subsidiary"} }