Hi, I need to update the last purchase price on inventory item based on location when the purchase order is created, But I am getting error : USER_ERROR:Please enter value(s) for: Item Category ..... See the code below and please help.function updateLastPurchasePrice(type)
{
try {
if (type=='create'){
// we are here only on an update
var cnt=nlapiGetLineItemCount('item');
nlapiLogExecution("DEBUG", "cnt: ",cnt);
var loc=nlapiGetFieldValue('location');
//var type;
for (var i = 1; i <= cnt; i++) {
var itemtype=nlapiGetLineItemValue('item', 'itemtype', i);
nlapiLogExecution("DEBUG", "type: ",itemtype);
if (itemtype=='InvtPart'){
var itemrate=nlapiGetLineItemValue('item', 'rate', i);
var itemid=nlapiGetLineItemValue('item', 'item', i);
nlapiLogExecution("DEBUG", "itemid: ",itemid);
var itemobj=nlapiLoadRecord('inventoryitem',itemid);
//nlapiLogExecution("DEBUG", "cnt: ",cnt);
var loccnt=itemobj.getLineItemCount('locations');
nlapiLogExecution("DEBUG", "loccnt: ",loccnt);
for (var j = 1; j <= loccnt; j++) {
var locid=itemobj.getLineItemValue('locations', 'location', j);
nlapiLogExecution("DEBUG", "locid: ",locid);
if (locid==loc){
itemobj.setLineItemValue('locations', 'lastpurchasepricemli', j,itemrate);
break;
}
}
nlapiSubmitRecord(itemobj);
//nlapiSubmitField('inventoryitem', itemid, 'lastpurchaseprice',itemrate);
}
}
}
} catch (e) {
nlapiLogExecution('ERROR', 'error details', (e.name || e.getCode()) + ":" + (e.message || e.getDetails()));
}
}