I am trying to write a script that uses the nlapiSubmitField function but I can't seem to get it to work.
I had some help writing the following line and I can't seem to understand what is happening here.
this function is on the item receipt record.
if (nlapiGetLineItemValue('item', 'upc', i))
{
nlapiSubmitField('inventoryitem', nlapiGetLineItemValue('item', 'item', i), 'upccode', nlapiGetLineItemValue('item', 'upc', i));
}
what I THINK is happening is:
1) (nlapiGetLineItemValue('item', 'upc', i)) is scanning through the line items on the item receipt and looking to see if the UPC field is populated
2) IF the UPC field is populated then
3) nlapiSubmitField('inventoryitem', is telling the code that it will be writting the values back to an inventory item record
4) nlapiGetLineItemValue('item', 'item', i) is telling the code to get the item number from the line item
5) 'upccode' is telling the code that I will be writing the value back to the UPCCODE field of the inventory item record
6) nlapiGetLineItemValue('item', 'upc', i)) is telling the code to GET the UPC code from the line item on the item receipt to write back to the inventory item.
am I missing something????
---------------
Here is the complete script if anyone is willing to help me. I have used the Suitescript developers guide, I have posted prior user group posts but I still can't get this thing to run.
function save_calculateItemReceipt(type, name){
var itemCount = 0;
for (var i = 1; i <= nlapiGetLineItemCount('item'); i++) {
if (nlapiGetLineItemValue('item', 'itemtype', i) == 'InvtPart') {
if (nlapiGetLineItemValue('item', 'quantity', i)) {
itemCount += parseInt(nlapiGetLineItemValue('item', 'quantity', i), 10);
}
if (nlapiGetLineItemValue('item', 'upc', i)) {
nlapiSubmitField('inventoryitem', nlapiGetLineItemValue('item', 'item', i), 'upccode', nlapiGetLineItemValue('item', 'upc', i));
}
}
}
nlapiSetFieldValue('custbody_rec_qty', itemCount);
return true;
}