The common problem facing during the loading of item records is with the item type. Items must be qualified by type before performing conventional record operations. A quick function that illustrates the lookups needed to know the item type and the equivalent load record operation.
function loadItemRecord(id){
var CONST_ITEMTYPE = {
'Assembly' : 'assemblyitem',
'Description' : 'descriptionitem',
'Discount' : 'discountitem',
'GiftCert' : 'giftcertificateitem',
'InvtPart' : 'inventoryitem',
'Group' : 'itemgroup',
'Kit' : 'kititem',
'Markup' : 'markupitem',
'NonInvtPart' : 'noninventoryitem',
'OthCharge' : 'otherchargeitem',
'Payment' : 'paymentitem',
'Service' : 'serviceitem',
'Subtotal' : 'subtotalitem'
};
try {
return record.load({
type: CONST_ITEMTYPE[search.lookupFields({
type: "item",
id: id,
columns: ["type"]
}).type[0].value],
id: id
});
}
catch(e) {
console.log('ERROR - loadItem failed with error: id:' + id, e.message)
};
};